From 9d7a837add968948a0d86a5c2e08d47871ac9871 Mon Sep 17 00:00:00 2001 From: Gianluca Casati Date: Fri, 26 Aug 2016 13:41:30 +0200 Subject: [PATCH] added alias: git undo (#123) Credits to [Enrico Campidoglio](http://megakemp.com/about/), see [original article](http://megakemp.com/2016/08/25/git-undo/). --- README.md | 6 ++++++ tips.json | 3 +++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 95bdcac..fd0f084 100644 --- a/README.md +++ b/README.md @@ -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) @@ -942,5 +943,10 @@ git revert -m 1 git rev-list --count ``` +## Alias: git undo +```sh +git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f' +``` + diff --git a/tips.json b/tips.json index 0c35cd8..4aff636 100644 --- a/tips.json +++ b/tips.json @@ -403,4 +403,7 @@ },{ "title": "Number of commits in a branch", "tip": "git rev-list --count " +},{ + "title": "Alias: git undo", + "tip": "git config --global alias.undo '!f() { git reset --hard $(git rev-parse --abbrev-ref HEAD)@{${1-1}}; }; f'" }]