How to rollback one particular commit in Git? -
here's situation:
about 10 commits ago, accidentally did bad commit. switching between unix/windows, , long story short, did commit every file changed, due line endings.
i had done 10 commits after that.
i realize in order push remote repository, need undo commit step (1) (there's setting in
.gitattributes
i've modified normalize).
how go point in time , not commit every file? , need re-commit other 9 changes after that?
if haven't pushed 10 commits yet, or remote repo private , not shared other people, can try using interactive rebase:
$ git rebase -i head~10 # go 10 commits in time.
in todo list of commits, choose edit
1 @ top of list:
edit d6627aa commit message 1 pick 0efdaca commit message 2 pick 9ec752f commit message 3 pick c84bf57 commit message 4 pick d4bcd50 commit message 5 pick c0110c9 commit message 6 pick 6606d13 commit message 7 pick 22933be commit message 8 pick cab2453 commit message 9 pick 05add41 commit message 10
then amend last commit change line endings want:
# modify .gitattributes, amend last commit $ git commit --amend $ git rebase --continue
to learn more rebasing, see rewriting history section of free online pro git book, official linux kernel git documentation rebase
.
Comments
Post a Comment