From 0a2f618d0f6594eaa8127e02f469b97eedfd29c6 Mon Sep 17 00:00:00 2001 From: Dan Dascalescu Date: Sun, 30 Nov 2014 17:21:34 -0800 Subject: [PATCH] Add a few recipes --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index d61035c..fb88198 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Flight rules for git +How to solve common git problems. ### What are "flight rules"? @@ -373,3 +374,32 @@ README.md foo.txt ``` Voila! We got our removed file back. Git reflog is also useful when rebasing goes terribly wrong. + + +## Delete/remove last pushed commit +``` +git reset HEAD^ --hard +git push -f [remote] [branch] +``` + + +## Delete/remove arbitrary commit +``` +git rebase --onto SHA1_OF_BAD_COMMIT^ SHA1_OF_BAD_COMMIT +git push -f [remote] [branch] +``` + + +## Delete tag +``` +git tag -d +git push :refs/tags/ +``` + + +## Clone all submodules +``` +git clone --recursive git://github.com/foo/bar.git +# if already cloned: +git submodule update --init --recursive +```