Skip to content

Instantly share code, notes, and snippets.

@oleiade
Created May 10, 2017 09:04
Show Gist options
  • Save oleiade/c9cfe399e0cdd2cdf43d6bba04ec95f8 to your computer and use it in GitHub Desktop.
Save oleiade/c9cfe399e0cdd2cdf43d6bba04ec95f8 to your computer and use it in GitHub Desktop.
A Git Cheat Sheet

Porcelain

Plumbing

``bash

Check that there are no commit history/objects corrupted

$ git fsck --full --strict

Get the tree hash a commit is pointing at

$ git rev-parse '6fea31^{tree}'

Find the latest anotated tag before HEAD

$ git describe HEAD

Find the latest tag (independant of anotation) before HEAD commit

$ git describe --tags HEAD

Filter a git command results that has the provided words in them

$ git log/rev-parse/cat-file/... :/some words

Apply a git command to a commit's version of a file

$ git mycommand REF : FILE $ git show 4fda159b:myfile.txt

In the scenario of a merge or rebase conflict, allows you to visualize

the different conflicting versions of a file

$ git show :0:FILE # Current staged file's content $ git show :1:FILE # Common ancestor file's content $ git show :2:FILE # Targets file's content $ git show :3:FILE # Mergigin in file's content

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