moving changed files to another branch for check-in

前端 未结 4 1623
独厮守ぢ
独厮守ぢ 2020-12-22 15:24

This often happens to me: I write some code, go to check in my changes, and then realize I\'m not in the proper branch to check in those changes. However I can\'t switch to

4条回答
  •  北海茫月
    2020-12-22 16:17

    git stash is your friend.

    If you have not made the commit yet, just run git stash. This will save away all of your changes.

    Switch to the branch you want the changes on and run git stash pop.

    There are lots of uses for git stash. This is certainly one of the more useful reasons.

    An example:

    # work on some code
    git stash
    git checkout correct-branch
    git stash pop
    

提交回复
热议问题