Skip to content

Commit 1795cb9

Browse files
authored
Add new command "Checkout previous branch" (#4728)
## **PR Description** I added a new feature to checkout to the last branch. I think it would be convenient to be able to checkout to the last branch with just one key stroke(`-`) in some cases, such as when switching between multiple branches during code review. Off course, I know that you can same thing by entering `"-"` to the text input of "Checkout by name" or using custom command but I think `git checkout -` is occasional use case. So I feel this feature can be a part of default features. Another advantage of this feature is that you can checkout to the last branch regardless of cursor position. Being able to switch branches without worrying about cursor position reduces stress I think.
2 parents 7d92260 + d41668f commit 1795cb9

16 files changed

+86
-6
lines changed

docs/Config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ keybinding:
627627
copyPullRequestURL: <c-y>
628628
checkoutBranchByName: c
629629
forceCheckoutBranch: F
630+
checkoutPreviousBranch: '-'
630631
rebaseBranch: r
631632
renameBranch: R
632633
mergeIntoCurrentBranch: M

docs/keybindings/Keybindings_en.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
170170
| `` o `` | Create pull request | |
171171
| `` O `` | View create pull request options | |
172172
| `` <c-y> `` | Copy pull request URL to clipboard | |
173-
| `` c `` | Checkout by name | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
173+
| `` c `` | Checkout by name | Checkout by name. In the input box you can enter '-' to switch to the previous branch. |
174+
| `` - `` | Checkout previous branch | |
174175
| `` F `` | Force checkout | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
175176
| `` d `` | Delete | View delete options for local/remote branch. |
176177
| `` r `` | Rebase | Rebase the checked-out branch onto the selected branch. |

docs/keybindings/Keybindings_ja.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ _凡例:`<c-b>` はctrl+b、`<a-b>` はalt+b、`B` はshift+bを意味
367367
| `` O `` | プルリクエスト作成オプションを表示 | |
368368
| `` <c-y> `` | プルリクエストURLをクリップボードにコピー | |
369369
| `` c `` | 名前でチェックアウト | 名前でチェックアウトします。入力ボックスに「-」を入力すると、最後のブランチをチェックアウトすることができます。 |
370+
| `` - `` | Checkout previous branch | |
370371
| `` F `` | 強制チェックアウト | 選択したブランチを強制的にチェックアウトします。これにより、選択したブランチをチェックアウトする前にワーキングディレクトリ内のすべてのローカル変更が破棄されます。 |
371372
| `` d `` | 削除 | ローカル/リモートブランチの削除オプションを表示します。 |
372373
| `` r `` | リベース | チェックアウトしたブランチを選択したブランチ上にリベースします。 |

docs/keybindings/Keybindings_ko.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
206206
| `` o `` | 풀 리퀘스트 생성 | |
207207
| `` O `` | 풀 리퀘스트 생성 옵션 | |
208208
| `` <c-y> `` | 풀 리퀘스트 URL을 클립보드에 복사 | |
209-
| `` c `` | 이름으로 체크아웃 | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
209+
| `` c `` | 이름으로 체크아웃 | Checkout by name. In the input box you can enter '-' to switch to the previous branch. |
210+
| `` - `` | Checkout previous branch | |
210211
| `` F `` | 강제 체크아웃 | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
211212
| `` d `` | 삭제 | View delete options for local/remote branch. |
212213
| `` r `` | 체크아웃된 브랜치를 이 브랜치에 리베이스 | Rebase the checked-out branch onto the selected branch. |

docs/keybindings/Keybindings_nl.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
103103
| `` o `` | Maak een pull-request | |
104104
| `` O `` | Bekijk opties voor pull-aanvraag | |
105105
| `` <c-y> `` | Kopieer de URL van het pull-verzoek naar het klembord | |
106-
| `` c `` | Uitchecken bij naam | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
106+
| `` c `` | Uitchecken bij naam | Checkout by name. In the input box you can enter '-' to switch to the previous branch. |
107+
| `` - `` | Checkout previous branch | |
107108
| `` F `` | Forceer checkout | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
108109
| `` d `` | Delete | View delete options for local/remote branch. |
109110
| `` r `` | Rebase branch | Rebase the checked-out branch onto the selected branch. |

docs/keybindings/Keybindings_pl.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ _Legenda: `<c-b>` oznacza ctrl+b, `<a-b>` oznacza alt+b, `B` oznacza shift+b_
137137
| `` O `` | Zobacz opcje tworzenia pull requesta | |
138138
| `` <c-y> `` | Kopiuj adres URL żądania ściągnięcia do schowka | |
139139
| `` c `` | Przełącz według nazwy | Przełącz według nazwy. W polu wprowadzania możesz wpisać '-' aby przełączyć się na ostatnią gałąź. |
140+
| `` - `` | Checkout previous branch | |
140141
| `` F `` | Wymuś przełączenie | Wymuś przełączenie wybranej gałęzi. To spowoduje odrzucenie wszystkich lokalnych zmian w drzewie roboczym przed przełączeniem na wybraną gałąź. |
141142
| `` d `` | Usuń | Wyświetl opcje usuwania lokalnej/odległej gałęzi. |
142143
| `` r `` | Przebazuj | Przebazuj przełączoną gałąź na wybraną gałąź. |

docs/keybindings/Keybindings_pt.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
9797
| `` O `` | View create pull request options | |
9898
| `` <c-y> `` | Copiar URL do pull request para área de transferência | |
9999
| `` c `` | Checar por nome | Checar por nome. Na caixa de entrada você pode inserir '-' para trocar para a última branch |
100+
| `` - `` | Checkout previous branch | |
100101
| `` F `` | Forçar checagem | Forçar checagem da branch selecionada. Isso irá descartar todas as mudanças no seu diretório de trabalho antes cheque a branch selecionada |
101102
| `` d `` | Apagar | Ver opções de exclusão para a branch local/remoto. |
102103
| `` r `` | Refazer | Refazer a branch checada na branch selecionada |

docs/keybindings/Keybindings_ru.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ _Связки клавиш_
204204
| `` o `` | Создать запрос на принятие изменений | |
205205
| `` O `` | Создать параметры запроса принятие изменений | |
206206
| `` <c-y> `` | Скопировать URL запроса на принятие изменений в буфер обмена | |
207-
| `` c `` | Переключить по названию | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
207+
| `` c `` | Переключить по названию | Checkout by name. In the input box you can enter '-' to switch to the previous branch. |
208+
| `` - `` | Checkout previous branch | |
208209
| `` F `` | Принудительное переключение | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
209210
| `` d `` | Delete | View delete options for local/remote branch. |
210211
| `` r `` | Перебазировать переключённую ветку на эту ветку | Rebase the checked-out branch onto the selected branch. |

docs/keybindings/Keybindings_zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ _图例:`<c-b>` 意味着ctrl+b, `<a-b>意味着Alt+b, `B` 意味着shift+b_
228228
| `` O `` | 创建拉取请求选项 | |
229229
| `` <c-y> `` | 复制拉取请求 URL 到剪贴板 | |
230230
| `` c `` | 按名称检出 | 按名称检出。在输入框中,您可以输入'-' 来切换到最后一个分支。 |
231+
| `` - `` | Checkout previous branch | |
231232
| `` F `` | 强制检出 | 强制检出所选分支。这将在检出所选分支之前放弃工作目录中的所有本地更改。 |
232233
| `` d `` | 删除 | 查看本地/远程分支的删除选项 |
233234
| `` r `` | 变基 | 将检出的分支变基到所选的分支上。 |

docs/keybindings/Keybindings_zh-TW.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ _說明:`<c-b>` 表示 Ctrl+B、`<a-b>` 表示 Alt+B,`B`表示 Shift+B
279279
| `` o `` | 建立拉取請求 | |
280280
| `` O `` | 建立拉取請求選項 | |
281281
| `` <c-y> `` | 複製拉取請求的 URL 到剪貼板 | |
282-
| `` c `` | 根據名稱檢出 | Checkout by name. In the input box you can enter '-' to switch to the last branch. |
282+
| `` c `` | 根據名稱檢出 | Checkout by name. In the input box you can enter '-' to switch to the previous branch. |
283+
| `` - `` | Checkout previous branch | |
283284
| `` F `` | 強制檢出 | Force checkout selected branch. This will discard all local changes in your working directory before checking out the selected branch. |
284285
| `` d `` | 刪除 | View delete options for local/remote branch. |
285286
| `` r `` | 將已檢出的分支變基至此分支 | Rebase the checked-out branch onto the selected branch. |

0 commit comments

Comments
 (0)