git: Switch branch and ignore any changes without committing

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

    switching to a new branch losing changes:

    git checkout -b YOUR_NEW_BRANCH_NAME --force
    

    switching to an existing branch losing changes:

    git checkout YOUR_BRANCH --force
    

提交回复
热议问题