2013-05-29 107 views
20

我已經運行git的地位和Git中撤消多次提交還沒有被推到遠程

# 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個提交和修改不上演commiting到我的遠程倉庫之前提交。我怎樣才能做到這一點?

回答

24

這將扔掉工作樹和所有本地更改四個最新提交:

git reset --hard HEAD~4 
27

您也可以運行以下重置到遠程的HEAD:

git reset --hard <REMOTE>/<BRANCH_NAME> 

例如:

git reset --hard origin/master 
+0

我用它爲這個網站回購http://azdam.com和謝謝。 –