## See Also
git fetch origin
git reset --hard origin/<branch>
git clean -f -d
git push origin <branch> -f
git revert <sha1> -m <parentNumber>
ParentNumber: Under the commit in git log
there should be a list of parent commits. The parent number is the index of the commit in this list. You can check which parent is which using git log <commit>
.
To revert the following commit to parent eefe424ab
commit 92163d393606d7a7a934c60267568fb5a6554ab820
Merge: eefe424ab 16d6f3adf
$ git revert 92163d393606d7a7a934c60267568fb5a6554ab820 -m 1
git checkout <branch>
git fetch origin
git reset --hard origin/<branch>
git checkout <sha1>
git rebase --interactive HEAD~N
Where N
is the number of commits to squash.
Text editor pops up:
pick 0eaeb7 Commit1
pick 12a660 Commit2
pick 6d3940 Commit3
Change all but the first pick
to squash
:
pick 0eaeb7 Commit1
squash 12a660 Commit2
squash 6d3940 Commit3
Save & close. Text editor pops up allowing you to set a new commit message. Change, save & close.
git reflog -3
git reset --soft HEAD@{1}
git branch