gitbash 1.9.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -89
- package/bin/gitbash +345 -723
- package/commands/_utils.sh +485 -157
- package/commands/branch.sh +9 -12
- package/commands/cleanstash.sh +47 -122
- package/commands/cleanup.sh +305 -441
- package/commands/commit.sh +136 -172
- package/commands/commits.sh +81 -114
- package/commands/create.sh +231 -314
- package/commands/pr.sh +158 -146
- package/commands/stale.sh +137 -277
- package/commands/stash.sh +11 -39
- package/commands/stashes.sh +10 -13
- package/commands/status.sh +197 -250
- package/commands/switch.sh +186 -274
- package/commands/unstash.sh +45 -109
- package/commands/update.sh +123 -142
- package/docs/CONTRIBUTING.md +16 -5
- package/docs/SECURITY.md +14 -3
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -17,21 +17,47 @@ npm i -g gitbash && gitbash --config
|
|
|
17
17
|
```bash
|
|
18
18
|
gitbash --help # Show help
|
|
19
19
|
gitbash --version # Show version
|
|
20
|
-
gitbash --init # Print shell
|
|
20
|
+
gitbash --init # Print shell functions (see Shell integration)
|
|
21
21
|
gitbash --config # Interactive configuration wizard
|
|
22
|
-
gitbash --config-local # Configure
|
|
23
|
-
gitbash --config-user # Configure
|
|
22
|
+
gitbash --config-local # Configure overrides for the current repository (committed)
|
|
23
|
+
gitbash --config-user # Configure personal overrides for the current repository
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### Dependencies
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
+
# Required
|
|
30
|
+
git >= 2.23, bash >= 3.2
|
|
31
|
+
|
|
29
32
|
# Optional (recommended)
|
|
30
|
-
brew install fzf # Interactive menus and previews
|
|
33
|
+
brew install fzf # Interactive menus and previews (fzf >= 0.36)
|
|
31
34
|
brew install git-delta # Better diff highlighting
|
|
32
35
|
brew install bat # File preview with syntax highlighting
|
|
33
36
|
```
|
|
34
37
|
|
|
38
|
+
### Shell integration
|
|
39
|
+
|
|
40
|
+
Add to your `.zshrc` or `.bashrc` to call the commands without the `gitbash` prefix:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
eval "$(gitbash --init)" # commit, switch, status, ...
|
|
44
|
+
eval "$(gitbash --init --prefix=gb-)" # gb-commit, gb-switch, ... (avoids shadowing e.g. /usr/bin/pr)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This defines small wrapper functions; every command still runs in its own bash process, so nothing else is added to your shell. Individual aliases work too, e.g. `alias commit="gitbash commit"`.
|
|
48
|
+
|
|
49
|
+
### Upgrading to 2.0
|
|
50
|
+
|
|
51
|
+
2.0 is a security and safety release. What changes for you:
|
|
52
|
+
|
|
53
|
+
- **Restart your shell** after upgrading, so `eval "$(gitbash --init)"` picks up the new wrapper functions.
|
|
54
|
+
- Config files are **read, not executed**: only plain `GITBASH_*="value"` lines are used, other lines are ignored with a warning. `GITBASH_MERGE_COMMAND` is ignored in a committed `.gitbashrc`.
|
|
55
|
+
- `status` no longer commits and pushes after staging. Use `Ctrl-O` to commit.
|
|
56
|
+
- `stale` toggles all/stale branches with `Ctrl-T` (was `Ctrl-A`).
|
|
57
|
+
- Protected branches (base branch and `GITBASH_PROTECTED_BRANCHES`) are never offered for deletion. `cleanup` and `switch` delete with `git branch -d` and ask again before force-deleting unmerged work.
|
|
58
|
+
- When your branch and the remote diverged, `commit -p`, `pr -p` and `update -p` ask whether to rebase, merge or abort instead of rebasing silently.
|
|
59
|
+
- fzf 0.36 or newer is required for the interactive menus.
|
|
60
|
+
|
|
35
61
|
## Commands
|
|
36
62
|
|
|
37
63
|
### branch
|
|
@@ -47,13 +73,15 @@ branch --version # Show version
|
|
|
47
73
|
### create
|
|
48
74
|
|
|
49
75
|
```bash
|
|
50
|
-
create [JIRA_LINK|ISSUE] [TITLE...]
|
|
76
|
+
create [--feature|--bugfix|--hotfix|--release|-t] [--push|--no-push] [JIRA_LINK|ISSUE] [TITLE...]
|
|
51
77
|
```
|
|
52
78
|
|
|
53
|
-
Create
|
|
79
|
+
Create a branch from the latest `origin/<base>` with optional Jira parsing, then push and track it (`GITBASH_CREATE_AUTO_PUSH`, `--no-push`).
|
|
54
80
|
|
|
55
81
|
**Branch Name Format:** `<type>/<custom-prefix>/<issue>-<title>` or `<type>/<custom-prefix>/<title>`
|
|
56
82
|
|
|
83
|
+
Issue keys like `PROJ-123`, `AB2-45` or `proj-7`, or a Jira URL. Titles are lower-cased, umlauts and accents transliterated (`Über` → `ueber`).
|
|
84
|
+
|
|
57
85
|
**Examples with custom prefix** (`GITBASH_CREATE_BRANCH_PREFIX="awesome-team"`):
|
|
58
86
|
|
|
59
87
|
With issue parsing enabled (default):
|
|
@@ -75,17 +103,10 @@ create # Interactive mode (no Jira prompt)
|
|
|
75
103
|
|
|
76
104
|
**Examples with empty prefix** (`GITBASH_CREATE_BRANCH_PREFIX=""`, default):
|
|
77
105
|
|
|
78
|
-
With parsing enabled:
|
|
79
|
-
|
|
80
106
|
```bash
|
|
81
107
|
create PROJ-123 fix bug # → feature/PROJ-123-fix-bug
|
|
82
108
|
create fix bug # → feature/NOISSUE-fix-bug
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
With parsing disabled:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
create enhance login screen # → feature/enhance-login-screen
|
|
109
|
+
create enhance login screen # → feature/enhance-login-screen (parsing disabled)
|
|
89
110
|
```
|
|
90
111
|
|
|
91
112
|
### switch
|
|
@@ -94,7 +115,9 @@ create enhance login screen # → feature/enhance-login-screen
|
|
|
94
115
|
switch [FILTER...]
|
|
95
116
|
```
|
|
96
117
|
|
|
97
|
-
Switch branches with fzf. Shows local
|
|
118
|
+
Switch branches with fzf. Shows local branches (`merged:` = fully merged into the base branch), then remote branches without a local copy. Preview shows commit history. If exactly one branch name matches the filter, switches directly. After switching, offers to fast-forward a branch that is behind.
|
|
119
|
+
|
|
120
|
+
- `Del` deletes the selected local branch (asks first, default no; unmerged commits need a second confirmation)
|
|
98
121
|
|
|
99
122
|
```bash
|
|
100
123
|
switch # Browse all branches
|
|
@@ -104,28 +127,40 @@ switch captcha # Pre-filter for "captcha"
|
|
|
104
127
|
### commit
|
|
105
128
|
|
|
106
129
|
```bash
|
|
107
|
-
commit [
|
|
130
|
+
commit [-p] [-s] [-a] [-t] [-y] [--force-with-lease] [MESSAGE...] [-- MESSAGE...]
|
|
108
131
|
```
|
|
109
132
|
|
|
110
|
-
Commit with optional push.
|
|
133
|
+
Commit with optional push.
|
|
134
|
+
|
|
135
|
+
- Only staged changes → commits them. Only unstaged/new files → stages everything (lists new files first).
|
|
136
|
+
- Both staged and unstaged → asks `[s]taged only` (default) or `[a]ll`.
|
|
137
|
+
- `-p` pushes; new branches get tracking. If the remote diverged, asks: rebase, merge or abort.
|
|
138
|
+
- `--amend` without a message keeps the old one; with `-p` it asks before `push --force-with-lease`.
|
|
111
139
|
|
|
112
140
|
```bash
|
|
113
|
-
commit fix bug # Commit
|
|
141
|
+
commit fix bug # Commit
|
|
114
142
|
commit -s fix bug # Commit staged only
|
|
115
143
|
commit -p add feature # Commit and push
|
|
144
|
+
commit -t add endpoint # Conventional commit type menu (feat, fix, ...)
|
|
145
|
+
commit --amend # Amend, keep message
|
|
116
146
|
```
|
|
117
147
|
|
|
118
148
|
### status
|
|
119
149
|
|
|
120
|
-
Interactive staging with fzf
|
|
150
|
+
Interactive staging with fzf and diff previews.
|
|
151
|
+
|
|
152
|
+
- `Enter` stages the selected files (unstages fully staged ones)
|
|
153
|
+
- `Ctrl-R` discards changes (asks first)
|
|
154
|
+
- `Ctrl-O` commits the staged changes, then asks whether to push
|
|
155
|
+
- `ESC` exits
|
|
121
156
|
|
|
122
157
|
### pr
|
|
123
158
|
|
|
124
159
|
```bash
|
|
125
|
-
pr [-p|--push]
|
|
160
|
+
pr [-p|--push] [--print]
|
|
126
161
|
```
|
|
127
162
|
|
|
128
|
-
Open
|
|
163
|
+
Open the pull request in the browser: the existing PR via the GitHub CLI when available, otherwise the create page (GitHub, GitHub Enterprise, GitLab, Bitbucket, Azure DevOps). Offers to commit local changes and to push a branch that is not on the remote yet. `-p` pushes first, `--print` prints the URL.
|
|
129
164
|
|
|
130
165
|
### update
|
|
131
166
|
|
|
@@ -133,21 +168,20 @@ Open PR in browser. `-p` pushes first.
|
|
|
133
168
|
update [-p|--push]
|
|
134
169
|
```
|
|
135
170
|
|
|
136
|
-
Merge latest
|
|
171
|
+
Merge the latest `origin/<base>` into the current branch. With local changes, asks to commit, stash (restored afterwards) or abort. Lists conflicts and opens the merge tool (`GITBASH_MERGE_COMMAND`). On the base branch itself, fast-forwards it.
|
|
137
172
|
|
|
138
173
|
### stale
|
|
139
174
|
|
|
140
175
|
```bash
|
|
141
|
-
stale [-a|--all] [--age=N] [--json] [FILTER...]
|
|
176
|
+
stale [-a|--all] [-m|--my] [--age=N] [--json] [FILTER...]
|
|
142
177
|
```
|
|
143
178
|
|
|
144
|
-
List remote branches
|
|
179
|
+
List remote branches older than 3 months (oldest first). Multi-select with TAB, Enter deletes them from the remote after confirmation. Protected branches are never listed.
|
|
145
180
|
|
|
146
|
-
-
|
|
147
|
-
- `-
|
|
148
|
-
- `--age=N` sets
|
|
149
|
-
- `
|
|
150
|
-
- `--json` outputs JSON for scripting (same format as cleanup)
|
|
181
|
+
- `-a|--all` starts with all branches (not only stale ones); `Ctrl-T` toggles
|
|
182
|
+
- `-m|--my` pre-fills the filter with your git username
|
|
183
|
+
- `--age=N` sets the threshold in months (default: 3, or `GITBASH_STALE_MONTHS`)
|
|
184
|
+
- `--json` outputs JSON for scripting
|
|
151
185
|
|
|
152
186
|
### stashes
|
|
153
187
|
|
|
@@ -163,7 +197,7 @@ Create named stash (includes untracked files).
|
|
|
163
197
|
|
|
164
198
|
### unstash
|
|
165
199
|
|
|
166
|
-
Apply stash with fzf picker.
|
|
200
|
+
Apply stash with fzf picker. Drops it afterwards unless you say no.
|
|
167
201
|
|
|
168
202
|
### cleanstash
|
|
169
203
|
|
|
@@ -172,16 +206,17 @@ Delete stashes (multi-select with TAB).
|
|
|
172
206
|
### cleanup
|
|
173
207
|
|
|
174
208
|
```bash
|
|
175
|
-
cleanup [--json]
|
|
209
|
+
cleanup [--dry-run] [--days=N] [-y|--yes] [--json]
|
|
176
210
|
```
|
|
177
211
|
|
|
178
|
-
Find and delete leftover local branches
|
|
212
|
+
Find and delete leftover local branches:
|
|
179
213
|
|
|
180
|
-
- **[MERGED]** -
|
|
181
|
-
- **[STALE]** - No commits in 7+ days
|
|
214
|
+
- **[MERGED]** - Changes are in the base branch (also squash merges). Pre-selected if the remote branch is gone or it is older than N days.
|
|
215
|
+
- **[STALE]** - No commits in 7+ days. Pre-selected only if everything is pushed.
|
|
216
|
+
- **[GONE]** - Remote branch deleted but changes not merged (not selected)
|
|
182
217
|
- **[RECENT]** - Recent activity (not selected)
|
|
183
218
|
|
|
184
|
-
Switches to
|
|
219
|
+
Unpushed commits are shown per branch. Deletes with `git branch -d`; force-deleting unmerged work needs a second confirmation. Switches to the base branch first if the current branch is deleted. `--dry-run` lists and `--yes` deletes the pre-selected branches without the picker.
|
|
185
220
|
|
|
186
221
|
`--json` outputs non-interactive JSON for scripting:
|
|
187
222
|
|
|
@@ -192,7 +227,10 @@ Switches to main/master first if current branch is selected for deletion.
|
|
|
192
227
|
"author_email": "dev@example.com",
|
|
193
228
|
"author_name": "Dev",
|
|
194
229
|
"name": "feature/old",
|
|
195
|
-
"last_change_relative": "2 weeks ago"
|
|
230
|
+
"last_change_relative": "2 weeks ago",
|
|
231
|
+
"category": "merged",
|
|
232
|
+
"preselected": true,
|
|
233
|
+
"unpushed_commits": 0
|
|
196
234
|
}
|
|
197
235
|
]
|
|
198
236
|
```
|
|
@@ -203,93 +241,66 @@ Switches to main/master first if current branch is selected for deletion.
|
|
|
203
241
|
commits [COUNT]
|
|
204
242
|
```
|
|
205
243
|
|
|
206
|
-
List recent commits with option to revert. Multi-select with TAB
|
|
244
|
+
List recent commits with option to revert. Multi-select with TAB; selected commits are reverted newest first.
|
|
207
245
|
|
|
208
246
|
```bash
|
|
209
247
|
commits # Show last 20 commits
|
|
210
248
|
commits 50 # Show last 50 commits
|
|
211
249
|
```
|
|
212
250
|
|
|
213
|
-
|
|
251
|
+
## Configuration
|
|
214
252
|
|
|
215
|
-
gitbash reads
|
|
253
|
+
gitbash reads `~/.gitbashrc`. Run `gitbash --config` to set it up interactively, or write it by hand:
|
|
216
254
|
|
|
217
255
|
```bash
|
|
218
256
|
# Branch prefix inserted between type and issue number (default: "")
|
|
219
|
-
# No trailing slash needed - it's added automatically
|
|
220
|
-
# Format: <type>/<prefix>/<issue>-<title> or <type>/<prefix>/<title>
|
|
221
|
-
# Examples: "awesome-team" or "" for no prefix
|
|
222
257
|
GITBASH_CREATE_BRANCH_PREFIX=""
|
|
223
258
|
|
|
224
|
-
# Merge tool command invoked by 'update' when conflicts occur (default: "fork")
|
|
225
|
-
GITBASH_MERGE_COMMAND="fork"
|
|
226
|
-
|
|
227
259
|
# Disable Jira issue number parsing in branch names: yes or no (default: "no")
|
|
228
260
|
GITBASH_CREATE_NO_ISSUE_PARSING="no"
|
|
229
261
|
|
|
230
262
|
# Fallback prefix when no issue number is provided (default: "NOISSUE")
|
|
231
|
-
# Only used when GITBASH_CREATE_NO_ISSUE_PARSING="no"
|
|
232
263
|
GITBASH_CREATE_ISSUE_PARSING_FALLBACK="NOISSUE"
|
|
233
264
|
|
|
234
|
-
#
|
|
235
|
-
|
|
265
|
+
# Push new branches right after 'create': yes or no (default: "yes")
|
|
266
|
+
GITBASH_CREATE_AUTO_PUSH="yes"
|
|
236
267
|
|
|
237
|
-
#
|
|
238
|
-
|
|
268
|
+
# Merge tool invoked by 'update' on conflicts (default: "fork")
|
|
269
|
+
GITBASH_MERGE_COMMAND="fork"
|
|
239
270
|
|
|
240
|
-
#
|
|
241
|
-
|
|
242
|
-
```
|
|
271
|
+
# Theme for delta/bat: auto, dark or light (default: "auto")
|
|
272
|
+
GITBASH_THEME="auto"
|
|
243
273
|
|
|
244
|
-
|
|
274
|
+
# Stale thresholds: 'stale' in months, 'cleanup' in days (defaults: 3, 7)
|
|
275
|
+
GITBASH_STALE_MONTHS="3"
|
|
276
|
+
GITBASH_CLEANUP_DAYS="7"
|
|
245
277
|
|
|
246
|
-
|
|
278
|
+
# Branches never offered for deletion, space-separated globs
|
|
279
|
+
GITBASH_PROTECTED_BRANCHES="main master develop release/*"
|
|
280
|
+
|
|
281
|
+
# Base branch (default: detected from origin/HEAD, then main, then master)
|
|
282
|
+
GITBASH_BASE_BRANCH=""
|
|
247
283
|
|
|
248
|
-
|
|
284
|
+
# Remote name (default: "origin")
|
|
285
|
+
GITBASH_REMOTE="origin"
|
|
286
|
+
```
|
|
249
287
|
|
|
250
|
-
|
|
288
|
+
Config files are **read, never executed**. Only `GITBASH_*="value"` lines are used (double, single or no quotes, optional `export`, `# comments`). Values cannot contain `$`, backticks, backslashes or quotes; anything else is ignored with a warning.
|
|
251
289
|
|
|
252
|
-
|
|
253
|
-
- Project-specific issue parsing settings
|
|
254
|
-
- Different stale/cleanup thresholds per repository
|
|
290
|
+
#### Local Configuration
|
|
255
291
|
|
|
256
|
-
|
|
292
|
+
Run `gitbash --config-local` inside a repository to create a committed `.gitbashrc` with overrides for everyone working on it (e.g. a team branch prefix or different thresholds). For security, a committed `.gitbashrc` cannot set `GITBASH_MERGE_COMMAND`.
|
|
257
293
|
|
|
258
294
|
#### User Configuration
|
|
259
295
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
User settings override both global (`~/.gitbashrc`) and local (`.gitbashrc`) settings. The file is automatically added to `.gitignore`.
|
|
296
|
+
Run `gitbash --config-user` to create `.gitbashrc-user` for personal overrides in one repository. It is excluded from git via `.git/info/exclude`.
|
|
263
297
|
|
|
264
298
|
**Configuration priority (highest to lowest):**
|
|
265
299
|
|
|
266
|
-
1. `.gitbashrc-user` -
|
|
267
|
-
2. `.gitbashrc` - Repository settings (
|
|
300
|
+
1. `.gitbashrc-user` - Personal settings for this repository (not committed)
|
|
301
|
+
2. `.gitbashrc` - Repository settings (committed)
|
|
268
302
|
3. `~/.gitbashrc` - Global settings
|
|
269
303
|
|
|
270
|
-
### Individual aliases
|
|
271
|
-
|
|
272
|
-
Instead of adding every command via `eval "$(gitbash --init)"` in `.zshrc` or `.bashrc`
|
|
273
|
-
direct usage with `gitbash [command]` is also possible. Or if desired, individual aliases
|
|
274
|
-
can be made.
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
alias branch="gitbash branch"
|
|
278
|
-
alias cleanstash="gitbash cleanstash"
|
|
279
|
-
alias cleanup="gitbash cleanup"
|
|
280
|
-
alias commit="gitbash commit"
|
|
281
|
-
alias commits="gitbash commits"
|
|
282
|
-
alias create="gitbash create"
|
|
283
|
-
alias pr="gitbash pr"
|
|
284
|
-
alias stale="gitbash stale"
|
|
285
|
-
alias stash="gitbash stash"
|
|
286
|
-
alias stashes="gitbash stashes"
|
|
287
|
-
alias status="gitbash status"
|
|
288
|
-
alias switch="gitbash switch"
|
|
289
|
-
alias unstash="gitbash unstash"
|
|
290
|
-
alias update="gitbash update"
|
|
291
|
-
```
|
|
292
|
-
|
|
293
304
|
## License
|
|
294
305
|
|
|
295
306
|
See [LICENSE](LICENSE) file for details.
|