Skip to content

Commit 9d7a837

Browse files
fibohemanth
authored andcommitted
added alias: git undo (#123)
Credits to [Enrico Campidoglio](http://megakemp.com/about/), see [original article](http://megakemp.com/2016/08/25/git-undo/).
1 parent 08096c7 commit 9d7a837

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
138138
* [Show how many lines does an author contribute](#show-how-many-lines-does-an-author-contribute)
139139
* [Revert: Reverting an entire merge](#revert-reverting-an-entire-merge)
140140
* [Number of commits in a branch](#number-of-commits-in-a-branch)
141+
* [Alias: git undo](#alias-git-undo)
141142

142143
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
143144
<!-- @doxie.inject end toc -->
@@ -942,5 +943,10 @@ git revert -m 1 <commit-ish>
942943
git rev-list --count <branch-name>
943944
```
944945

946+
## Alias: git undo
947+
```sh
948+
git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'
949+
```
950+
945951
<!-- Don’t remove or change the comment below – that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
946952
<!-- @doxie.inject end -->

tips.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,7 @@
403403
},{
404404
"title": "Number of commits in a branch",
405405
"tip": "git rev-list --count <branch-name>"
406+
},{
407+
"title": "Alias: git undo",
408+
"tip": "git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'"
406409
}]

0 commit comments

Comments
 (0)