added alias: git undo (#123)

Credits to [Enrico Campidoglio](http://megakemp.com/about/),
see [original article](http://megakemp.com/2016/08/25/git-undo/).
This commit is contained in:
Gianluca Casati 2016-08-26 13:41:30 +02:00 committed by hemanth.hm
parent 08096c7c71
commit 9d7a837add
2 changed files with 9 additions and 0 deletions

View File

@ -138,6 +138,7 @@ P.S: All these commands are tested on `git version 2.7.4 (Apple Git-66)`.
* [Show how many lines does an author contribute](#show-how-many-lines-does-an-author-contribute)
* [Revert: Reverting an entire merge](#revert-reverting-an-entire-merge)
* [Number of commits in a branch](#number-of-commits-in-a-branch)
* [Alias: git undo](#alias-git-undo)
<!-- Dont remove or change the comment below that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
<!-- @doxie.inject end toc -->
@ -942,5 +943,10 @@ git revert -m 1 <commit-ish>
git rev-list --count <branch-name>
```
## Alias: git undo
```sh
git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'
```
<!-- Dont remove or change the comment below that can break automatic updates. More info at <http://npm.im/doxie.inject>. -->
<!-- @doxie.inject end -->

View File

@ -403,4 +403,7 @@
},{
"title": "Number of commits in a branch",
"tip": "git rev-list --count <branch-name>"
},{
"title": "Alias: git undo",
"tip": "git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'"
}]