Rollback to last git commit

后端 未结 6 2113
时光取名叫无心
时光取名叫无心 2020-12-22 16:05

I just did a

git commit -m \"blah\"

then I added some files, how do I rollback and remove what is in my current files that have not yet be

6条回答
  •  半阙折子戏
    2020-12-22 16:30

    An easy foolproof way to UNDO local file changes since the last commit is to place them in a new branch:

    git branch changes
    git checkout changes
    git add .
    git commit
    

    This leaves the changes in the new branch. Return to the original branch to find it back to the last commit:

    git checkout master
    

    The new branch is a good place to practice different ways to revert changes without risk of messing up the original branch.

提交回复
热议问题