You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add new command "Move commits to new branch" (#3876)
- **PR Description**
Add a new command "Move commits to new branch" (bound to `N` by
default), which is useful if you have just started some new work, you
already made some commits, and then you realize that you forgot to
create a new branch first, accidentally making those commits on main or
whichever other feature branch you happened to be on.
If you made those commits on main, you are prompted for a branch name
for the new branch, and then it creates the new branch right there and
hard-resets main to where it was. If you made them on another feature
branch though, you are first given the choice whether you want to create
the new branch from main, or keep it stacked on that other feature
branch. Then it prompts you for the name and proceeds as above.
Inspired by Magit's
[magit-branch-spinoff](https://magit.vc/manual/magit/Branch-Commands.html#index-b-s)
command.
The conditions under which the command is available are rather
restrictive: the current branch must have an upstream, it must not be
behind its upstream, but it must be ahead of it (otherwise there
wouldn't be any commits to move, and you might as well just create a new
branch normally).
Copy file name to clipboardExpand all lines: docs/keybindings/Keybindings_en.md
+12
Original file line number
Diff line number
Diff line change
@@ -109,6 +109,9 @@ If you would instead like to start an interactive rebase from the selected commi
109
109
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
110
110
|`` o ``| Open commit in browser ||
111
111
|`` n ``| Create new branch off of commit ||
112
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
113
+
114
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
112
115
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
113
116
|`` C ``| Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
114
117
|`` <c-t> ``| Open external diff tool (git difftool) ||
@@ -166,6 +169,9 @@ If you would instead like to start an interactive rebase from the selected commi
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
173
+
174
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
169
175
|`` o ``| Create pull request ||
170
176
|`` O ``| View create pull request options ||
171
177
|`` <c-y> ``| Copy pull request URL to clipboard ||
@@ -266,6 +272,9 @@ If you would instead like to start an interactive rebase from the selected commi
266
272
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
267
273
|`` o ``| Open commit in browser ||
268
274
|`` n ``| Create new branch off of commit ||
275
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
276
+
277
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
269
278
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
270
279
|`` C ``| Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
@@ -347,6 +356,9 @@ If you would instead like to start an interactive rebase from the selected commi
347
356
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
348
357
|`` o ``| Open commit in browser ||
349
358
|`` n ``| Create new branch off of commit ||
359
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
360
+
361
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
350
362
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
351
363
|`` C ``| Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
Copy file name to clipboardExpand all lines: docs/keybindings/Keybindings_ja.md
+12
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,9 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
82
82
|`` y ``| コミットの情報をコピー | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
83
83
|`` o ``| ブラウザでコミットを開く ||
84
84
|`` n ``| コミットにブランチを作成 ||
85
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
86
+
87
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
85
88
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
86
89
|`` C ``| コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
@@ -133,6 +136,9 @@ If you would instead like to start an interactive rebase from the selected commi
133
136
|`` y ``| コミットの情報をコピー | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
134
137
|`` o ``| ブラウザでコミットを開く ||
135
138
|`` n ``| コミットにブランチを作成 ||
139
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
140
+
141
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
136
142
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
137
143
|`` C ``| コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
138
144
|`` <c-t> ``| Open external diff tool (git difftool) ||
@@ -250,6 +256,9 @@ If you would instead like to start an interactive rebase from the selected commi
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
260
+
261
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
253
262
|`` o ``| Pull Requestを作成 ||
254
263
|`` O ``| View create pull request options ||
255
264
|`` <c-y> ``| Pull RequestのURLをクリップボードにコピー ||
@@ -380,6 +389,9 @@ If you would instead like to start an interactive rebase from the selected commi
380
389
|`` y ``| コミットの情報をコピー | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
381
390
|`` o ``| ブラウザでコミットを開く ||
382
391
|`` n ``| コミットにブランチを作成 ||
392
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
393
+
394
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
383
395
|`` g ``| Reset | View reset options (soft/mixed/hard) for resetting onto selected item. |
384
396
|`` C ``| コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
Copy file name to clipboardExpand all lines: docs/keybindings/Keybindings_ko.md
+12
Original file line number
Diff line number
Diff line change
@@ -60,6 +60,9 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
60
60
|`` y ``| 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
61
61
|`` o ``| 브라우저에서 커밋 열기 ||
62
62
|`` n ``| 커밋에서 새 브랜치를 만듭니다. ||
63
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
64
+
65
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
63
66
|`` g ``| View reset options | View reset options (soft/mixed/hard) for resetting onto selected item. |
64
67
|`` C ``| 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
@@ -101,6 +104,9 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
101
104
|`` y ``| 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
102
105
|`` o ``| 브라우저에서 커밋 열기 ||
103
106
|`` n ``| 커밋에서 새 브랜치를 만듭니다. ||
107
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
108
+
109
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
104
110
|`` g ``| View reset options | View reset options (soft/mixed/hard) for resetting onto selected item. |
105
111
|`` C ``| 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
@@ -200,6 +206,9 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
200
206
|`` i ``| Git-flow 옵션 보기 ||
201
207
|`` <space> ``| 체크아웃 | Checkout selected item. |
202
208
|`` n ``| 새 브랜치 생성 ||
209
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
210
+
211
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
203
212
|`` o ``| 풀 리퀘스트 생성 ||
204
213
|`` O ``| 풀 리퀘스트 생성 옵션 ||
205
214
|`` <c-y> ``| 풀 리퀘스트 URL을 클립보드에 복사 ||
@@ -305,6 +314,9 @@ If you would instead like to start an interactive rebase from the selected commi
305
314
|`` y ``| 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
306
315
|`` o ``| 브라우저에서 커밋 열기 ||
307
316
|`` n ``| 커밋에서 새 브랜치를 만듭니다. ||
317
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
318
+
319
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
308
320
|`` g ``| View reset options | View reset options (soft/mixed/hard) for resetting onto selected item. |
309
321
|`` C ``| 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
310
322
|`` <c-t> ``| Open external diff tool (git difftool) ||
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
103
+
104
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
102
105
|`` o ``| Maak een pull-request ||
103
106
|`` O ``| Bekijk opties voor pull-aanvraag ||
104
107
|`` <c-y> ``| Kopieer de URL van het pull-verzoek naar het klembord ||
@@ -177,6 +180,9 @@ If you would instead like to start an interactive rebase from the selected commi
177
180
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
178
181
|`` o ``| Open commit in browser ||
179
182
|`` n ``| Creëer nieuwe branch van commit ||
183
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
184
+
185
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
180
186
|`` g ``| Bekijk reset opties | View reset options (soft/mixed/hard) for resetting onto selected item. |
181
187
|`` C ``| Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
182
188
|`` <c-t> ``| Open external diff tool (git difftool) ||
@@ -244,6 +250,9 @@ If you would instead like to start an interactive rebase from the selected commi
244
250
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
245
251
|`` o ``| Open commit in browser ||
246
252
|`` n ``| Creëer nieuwe branch van commit ||
253
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
254
+
255
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
247
256
|`` g ``| Bekijk reset opties | View reset options (soft/mixed/hard) for resetting onto selected item. |
248
257
|`` C ``| Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
@@ -347,6 +356,9 @@ If you would instead like to start an interactive rebase from the selected commi
347
356
|`` y ``| Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
348
357
|`` o ``| Open commit in browser ||
349
358
|`` n ``| Creëer nieuwe branch van commit ||
359
+
| `` N `` | Move commits to new branch | Create a new branch and move the unpushed commits of the current branch to it. Useful if you meant to start new work and forgot to create a new branch first.
360
+
361
+
Note that this disregards the selection, the new branch is always created either from the main branch or stacked on top of the current branch (you get to choose which). |
350
362
|`` g ``| Bekijk reset opties | View reset options (soft/mixed/hard) for resetting onto selected item. |
351
363
|`` C ``| Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `<esc>` to cancel the selection. |
0 commit comments