Modified files in a git branch are spilling over into another branch

后端 未结 5 1869
后悔当初
后悔当初 2020-11-22 09:01

I am working on a git repository with a master branch and another topic branch. I have switched to topic branch and modified a file. Now, if I switched to master branch that

5条回答
  •  春和景丽
    2020-11-22 09:35

    If you want to temporarily store your changes to one branch while you go off to do work on another, you can use the git stash command. It's one of the amazing little unsung perks of using git. Example workflow:

    git stash #work saved
    git checkout master
    #edit files
    git commit
    git checkout git-build
    git stash apply #restore earlier work
    

    git stash stores a stack of changes, so you can safely store multiple checkpoints. You can also give them names/descriptions. Full usage info here.

提交回复
热议问题