Closed brandondong closed 1 week ago
Funny, I was thinking about this too the other day. I ran into this several times in the past, and it's always annoying. I was about to make a PR for this sometime soon, but I have little time, and I wouldn't mind if you beat me to it, @brandondong. Wanna give it a try?
I suppose it would be nice to create some abstraction that lets us share the code between checkout and new branch, but I haven't checked if that's feasible. I would also be ok with simply duplicating the code from checkout, using the same approach.
Sure, can take a crack at it later.
Is your feature request related to a problem? Please describe. Sometimes, I'm on branch A and then I want to create and switch to a new branch based off of branch B. So I navigate to the B branch in the branches panel and press
n
. However, if I have changed files, this can present the git error where I must commit or stash my changes first. It's often the case that lazygit's autostash feature would have saved me but the functionality is not present in this flow.I don't see a reason why not. The action is basically the same as checking out B in terms of moving the HEAD pointer and the autostash feature is present there. Whenever I run into this, I just press
<space>
instead which triggers the autostash push and pop, and then pressn
.Describe the solution you'd like When creating a new branch and git returns the commit or stash error, offer to autostash.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Reproduction:
Checking out the other branch (
<space>
) will work but trying to create and switch to a new branch based off of it (n
) will not.