2011-08-11 45 views
2

我做这些操作:git,怎么回去?

$ bundle exec rspec spec/ 
$ git add . 
$ git commit -m "Finished layout and routes" 
$ git checkout master 
$ git merge filling-in-layout 
$ git push 
$ git push heroku 

但后来我发现搞砸程序。我想回到上次提交。本地和github和heroku。我怎样才能做到这一点?

回答

3

在你所有的分支,类型

git reset --hard HEAD^ 

这将重置,并放弃所有的修改最后一次提交。

,如果你不想放弃在错误的更改提交,你可以使用

git reset --mixed HEAD^ 
0

假设都masterfilling-in-layout你感动的分支:

# Reset master to its previous commit 
git checkout master 
git reset --hard [email protected]{1} 

# Reset filling-in-layout to its previous commit 
git checkout filling-in-layout 
git reset --hard [email protected]{1} 

# Push to GitHub, forcing the loss of history 
git push --force 

# Same, for the heroku remote 
git push --force heroku