我已经运行了git status和
# On branch master
# Your branch is ahead of 'origin/master' by 4 commits.
# (use "git push" to publish your local commits)
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/views/layouts/_header.html.erb
#
no changes added to commit (use "git add" and/or "git commit -a")
我希望在提交到我的远程存储库之前撤消所有4次提交和更改未提交的提交。我怎么能这样做?
答案 0 :(得分:32)
您还可以运行以下命令重置为遥控器的HEAD:
git reset --hard <REMOTE>/<BRANCH_NAME>
例如:
git reset --hard origin/master
答案 1 :(得分:25)
这将丢弃工作树中的所有本地更改以及最近的四个提交:
git reset --hard HEAD~4