Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2010-08-11 22:48:22
Size: 290
Editor: SamatJain
Comment:
Revision 3 as of 2010-09-06 08:56:10
Size: 705
Editor: SamatJain
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
=== Reverting changes ===

Amend the previous commit that has not been propogated (i.e. undo it, then start a new one with the pending changes in the index):

{{{
git commit --amend -a -m "New commit message"
}}}
Line 7: Line 15:
For a commit that has been propagated, there is no way to undo. However, the following will create a new commit undoing the previous commit's changes: Once a commit that has been propagated, there is no way to undo. However, the following will create a new commit undoing the previous commit's changes:
Line 12: Line 20:

=== Pull with rebase instead of merge ===

{{{
git pull --rebase
}}}

Configure a branch to always do a rebase instead of a merge:

{{{
git config branch.master.rebase true
}}}

Reverting changes

Amend the previous commit that has not been propogated (i.e. undo it, then start a new one with the pending changes in the index):

git commit --amend -a -m "New commit message"

Undo a commit that has not been propagated:

git reset --hard HEAD^

Once a commit that has been propagated, there is no way to undo. However, the following will create a new commit undoing the previous commit's changes:

git revert HEAD

Pull with rebase instead of merge

git pull --rebase

Configure a branch to always do a rebase instead of a merge:

git config branch.master.rebase true


CategoryCheatSheet

SamatsWiki: CheatSheet/Git (last edited 2023-03-01 08:30:42 by SamatJain)