Why do I have to stash / commit my changes before switching branches?

前端 未结 4 2122
不思量自难忘°
不思量自难忘° 2021-01-18 19:14

I find this to be annoying because I would like to quickly switch branches and do something and then switch back to what I was working on before. I realize I can stash and t

4条回答
  •  醉酒成梦
    2021-01-18 20:07

    One way to make this easier is to use something like Legit. One of the commands I like from Legit is git switch:

    $ git switch 
    # Switches to branch. Stashes and restores unstaged changes.
    

    Legit stores the stash with a description that follows a particular naming convention. That way, when you use git switch to return to the first branch, it can automatically unstash the changes saved for that branch.

提交回复
热议问题