1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

Add new command "Checkout previous branch"

This commit is contained in:
kyu08
2025-07-13 00:42:01 +09:00
committed by Stefan Haller
parent 7d92260050
commit 5b1292006d
5 changed files with 66 additions and 0 deletions

View File

@ -89,6 +89,11 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty
Description: self.c.Tr.CheckoutByName,
Tooltip: self.c.Tr.CheckoutByNameTooltip,
},
{
Key: opts.GetKey(opts.Config.Branches.CheckoutPreviousBranch),
Handler: self.checkoutPreviousBranch,
Description: self.c.Tr.CheckoutPreviousBranch,
},
{
Key: opts.GetKey(opts.Config.Branches.ForceCheckoutBranch),
Handler: self.forceCheckout,
@ -483,6 +488,11 @@ func (self *BranchesController) forceCheckout() error {
return nil
}
func (self *BranchesController) checkoutPreviousBranch() error {
self.c.LogAction(self.c.Tr.Actions.CheckoutBranch)
return self.c.Helpers().Refs.CheckoutRef("-", types.CheckoutRefOptions{})
}
func (self *BranchesController) checkoutByName() error {
self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.BranchName + ":",