还原提交文件

时间:2010-06-28 10:05:43

标签: git git-svn

在我的存储库中,当使用git-svn时,我得到了2个分支

$ git branch -a
* master
  remotes/git-svn

现在我可以看到带有

的差异
$ git diff --name-status remotes/git-svn
M       global/library/Exception.php

如何恢复修改? 感谢

1 个答案:

答案 0 :(得分:2)

试试这个:

# create new branch (just in case you have some modifications in master branch)
git checkout -b revert_wrong_commit
# svn switch
git reset --hard git-svn
# undo last commit (takes the patch from the commit and unapplies it)
git revert HEAD
# commit the reverted changes
git commit -a
# switch to master branch
git checkout master
# merge the changes from revert_wrong_commit branch
git merge revert_wrong_commit