git: Switch branch and ignore any changes without committing

后端 未结 15 2163
别跟我提以往
别跟我提以往 2020-11-28 00:37

I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that

15条回答
  •  臣服心动
    2020-11-28 00:47

    Follow these steps:

    1. Git stash save will save all your changes even if you switch between branches.
    git stash save
    
    1. Git checkout any other branch, now since you saved your changes you can move around any branch. The above command will make sure that your changes are saved.
    git checkout branch
    
    1. Now when you come back to the branch use this command to get all your changes back.
    git stash pop
    

提交回复
热议问题