Created
September 9, 2014 07:10
-
-
Save sharat/8a74c6e901fbe9a9ff5e to your computer and use it in GitHub Desktop.
How to use git revert?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git-revert $ git init | |
git-revert (master) $ touch 1.txt | |
git-revert (master) $ touch 2.txt | |
git-revert (master) $ git add . | |
git-revert (master) $ git commit -am "wanted commit 1" | |
[master (root-commit) 80395aa] wanted commit 1 | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100644 1.txt | |
create mode 100644 2.txt | |
git-revert (master) $ touch 3.txt | |
git-revert (master) $ touch 4.txt | |
git-revert (master) $ git add . | |
git-revert (master) $ git commit -am "wanted commit 2" | |
[master b54ab04] wanted commit 2 | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100644 3.txt | |
create mode 100644 4.txt | |
git-revert (master) $ touch 5.txt 6.txt | |
git-revert (master) $ git add . | |
git-revert (master) $ git commit -am "unwanted commit 1" | |
[master 30a89ba] unwanted commit 1 | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100644 5.txt | |
create mode 100644 6.txt | |
git-revert (master) $ touch 7.txt 8.txt | |
git-revert (master) $ git add . | |
git-revert (master) $ git commit -am "unwanted commit HEAD" | |
[master 4501a98] wanted commit 3 | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
create mode 100644 7.txt | |
create mode 100644 8.txt | |
git-revert (master) $ git lg | |
4501a989fd918ab13b5ddc8a417f7fe37f379caf wanted commit 3 | |
30a89ba605aa38c050a520b7312063f4afcfe947 unwanted commit 1 | |
b54ab04e6c57209b469d6b60b0dc3de9c2042d0b wanted commit 2 | |
80395aa942b5e1d50087e23487ba5b8778fc66c4 wanted commit 1 | |
git-revert (master) $ ls | |
1.txt 2.txt 3.txt 4.txt 5.txt 6.txt 7.txt 8.txt | |
# Reverting last commit | |
git-revert (master) $ git revert HEAD | |
[master 2db3742] last commit - Revert "unwanted commit HEAD" | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
delete mode 100644 7.txt | |
delete mode 100644 8.txt | |
git-revert (master) $ git lg | |
2db3742af69b09c211e96b1b99127de6c242fe48 last commit - Revert "unwanted commit HEAD" | |
4501a989fd918ab13b5ddc8a417f7fe37f379caf unwanted commit HEAD | |
30a89ba605aa38c050a520b7312063f4afcfe947 unwanted commit 1 | |
b54ab04e6c57209b469d6b60b0dc3de9c2042d0b wanted commit 2 | |
80395aa942b5e1d50087e23487ba5b8778fc66c4 wanted commit 1 | |
git-revert (master) $ git revert 30a89ba605aa38c050a520b7312063f4afcfe947 | |
[master caf20a6] Revert "unwanted commit 1" | |
2 files changed, 0 insertions(+), 0 deletions(-) | |
delete mode 100644 5.txt | |
delete mode 100644 6.txt | |
git-revert (master) $ git lg | |
caf20a62b4f2b39f4c58bf8a70d98226c936b44f Revert "unwanted commit 1" | |
2db3742af69b09c211e96b1b99127de6c242fe48 last commit - Revert "unwanted commit HEAD" | |
4501a989fd918ab13b5ddc8a417f7fe37f379caf unwanted commit HEAD | |
30a89ba605aa38c050a520b7312063f4afcfe947 unwanted commit 1 | |
b54ab04e6c57209b469d6b60b0dc3de9c2042d0b wanted commit 2 | |
80395aa942b5e1d50087e23487ba5b8778fc66c4 wanted commit 1 | |
git-revert (master) $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment