git: Switch branch and ignore any changes without committing

后端 未结 15 2139
别跟我提以往
别跟我提以往 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:44

    If you have made changes to files that Git also needs to change when switching branches, it won't let you. To discard working changes, use:

    git reset --hard HEAD
    

    Then, you will be able to switch branches.

提交回复
热议问题