Skip to content

Instantly share code, notes, and snippets.

@HotFusionMan
Last active December 18, 2015 02:09
Show Gist options
  • Save HotFusionMan/5708810 to your computer and use it in GitHub Desktop.
Save HotFusionMan/5708810 to your computer and use it in GitHub Desktop.
Git tips

how to list commits that are on one branch but not another (from http://stackoverflow.com/questions/1710894/using-git-show-all-commits-that-are-in-one-branch-but-not-the-others ): git log <branch_you_want_to_look_at> ^<branch_you_want_to_ignore> --no-merges You can specify multiple branches to ignore by adding more ^branchname arguments.

how to list branches that contain a given commit ("git branch --contains", "git cherry"): http://stackoverflow.com/questions/1419623/git-how-to-list-branches-that-contain-a-given-commit

The Illustrated Guide to Recovering Lost Commits with Git http://www.programblings.com/2008/06/07/the-illustrated-guide-to-recovering-lost-commits-with-git/

Find the last commit that affected a given path: git rev-list -n 1 HEAD -- <given_path> (cf. http://stackoverflow.com/questions/953481/restore-a-deleted-file-in-a-git-repo )

A Git alias to unstage files that have already been deleted: http://gistflow.com/posts/736-a-simple-git-alias-to-stage-git-rm-files-that-have-already-been-deleted

Checkout a single file from a stash (here, the most recent stash): git checkout stash@{0} -- the_path_of_the_desired_file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment