git reset HEAD~
Above command will reset your master pointing to the previous commit. From Git's point of view, it's done. The current HEAD (master) now points to the desired copy of the codes you want to have. But the problem is once you do a synchronization with SVN, it's going to be reset back to the copy you want to get rid of. This is because Git is treating master tag as a pointer. When you do the above reset, it just move the pointer back without doing any real commit. So here what we really need is a "real" commit, which "git revert" provides.
git revert HEADAfter this, if you look at the history, you'll find a commit with the new result. Now synchronize with SVN and you'll find a new commit in it and the changes you made has been rolled back.
Note, git revert should only use when you have pushed your changes to remote sites. Then it gives you a chance to fix the problem. If your change is still local, git reset is recommended.
Maybe this is stupid, but it took me a while to figure this out, hope this helps some one out there who is also bothered by this.
No comments:
Post a Comment