From 22ac3672848b522ad3b40894e1725b161870401f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 28 Aug 2010 01:12:23 -0400 Subject: [PATCH] Added git-undo for removing recent commits. --- Makefile | 3 ++- Readme.md | 11 +++++++++++ bin/git-undo | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 bin/git-undo diff --git a/Makefile b/Makefile index 1a80a6c..4bb872b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,8 @@ BINS = \ git-contrib \ git-update-extras \ git-extras-version \ - git-release + git-release \ + git-undo install: @echo "... installing to $(PREFIX)/bin" diff --git a/Readme.md b/Readme.md index 19b9729..3480308 100644 --- a/Readme.md +++ b/Readme.md @@ -207,6 +207,17 @@ Listing commits: * Added --all support to git-count * Initial commit +## git-undo + +Removes the latest commit + + git undo + +Remove the latest 3 commits: + + git undo 3 + + ## git-update-extras Updates git extras. clones the repo to _/tmp/git-extras_, make installs, then cds back to the origin directory. \ No newline at end of file diff --git a/bin/git-undo b/bin/git-undo new file mode 100755 index 0000000..363ec73 --- /dev/null +++ b/bin/git-undo @@ -0,0 +1,11 @@ +#!/bin/sh + +if test $# -eq 0; then + git reset --hard HEAD~1 +else + if `echo $1 | grep -q [^[:digit:]]`; then + echo $1 is not a number + else + git reset --hard HEAD~$1 + fi +fi \ No newline at end of file