From b77aa0974bf8ae1675ff03a28cad7d163203aeef Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Sat, 16 Jul 2016 18:19:35 +0530 Subject: [PATCH 1/2] Update git cheatsheet --- cheat/cheatsheets/git | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index b5c142b..82ded19 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -104,3 +104,20 @@ git clone --depth 1 # To unshallow a clone git pull --unshallow + +# Create a bare branch (one that has no commits on it) +git checkout --orphan branch_name + +# Checkout a new branch from a different starting point +git checkout -b master upstream/master + +# Remove all stale branches (ones that have been deleted on remote) +# So if you have a lot of useless branches, delete them on Github and then run this +git remote prune origin + +# The following can be used to prune all remotes at once +git remote prune $(git remote | tr '\n' ' ') + +# Revisions can also be identified with :/text +# So, this will show the first commit that has "cool" in their message body +git show :/cool From 70ad22c12e2d93d61fd11f4be7fac42955a92867 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Wed, 20 Jul 2016 14:34:29 +0530 Subject: [PATCH 2/2] git: Undo parts of last commit Added from: http://stackoverflow.com/a/4248269/2043048 --- cheat/cheatsheets/git | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cheat/cheatsheets/git b/cheat/cheatsheets/git index 82ded19..2a814b0 100644 --- a/cheat/cheatsheets/git +++ b/cheat/cheatsheets/git @@ -121,3 +121,6 @@ git remote prune $(git remote | tr '\n' ' ') # Revisions can also be identified with :/text # So, this will show the first commit that has "cool" in their message body git show :/cool + +# Undo parts of last commit in a specific file +git checkout -p HEAD^ -- /path/to/file