Skip to content

Instantly share code, notes, and snippets.

@rpowis
Created October 8, 2013 12:55
Show Gist options
  • Save rpowis/6884238 to your computer and use it in GitHub Desktop.
Save rpowis/6884238 to your computer and use it in GitHub Desktop.
Git tricks
# Apply a patch from another (unrelated) local repository
$ git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
# Checout an empty branch to do something radically different (i.e. gh-pages)
$ git checkout --orphan <new_empty_branch>
# Find the root of the project
$ git rev-parse --show-toplevel
# Change to the root of the project
$ cd $(git rev-parse --show-toplevel)
# Delete a remote branch
$ git push origin --delete <branchName>
# Show all the content in your stashes
$ for stash in $(git stash list | awk '{print $1}' | sed -e 's/://'); do
> (echo ----- $stash ----- && git stash show -p $stash);
> done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment