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

前端 未结 4 2077
不思量自难忘°
不思量自难忘° 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:13

    You can avoid it using git stash to stash your changes. Then you can change branch, then restore the branch and getting back your changes:

    $ git stash
    $ git checkout other_branch
    $ git checkout original_branch
    $ git stash pop
    

提交回复
热议问题