Skip to content

Instantly share code, notes, and snippets.

@lucamartellucci
Created March 11, 2016 14:10
Show Gist options
  • Save lucamartellucci/a6071d79d45c2e962f88 to your computer and use it in GitHub Desktop.
Save lucamartellucci/a6071d79d45c2e962f88 to your computer and use it in GitHub Desktop.
Git Cheat Sheet

Git Cheat Sheet

Show the commit history of the local repository

$ git log

Show the content of a given commit

$ git show <revhash>

Show the list of the modified projects of a git branch against the master branch

$ git diff --name-only master...[branch_name]  | awk -F"/" '{print $1}' | sort | uniq

Create local branch

$ git checkout -b [branch_name]

Create remote branch from local branch

$ git push -u origin [branch_name]

Discard unstaged changes

$ git checkout -- .

###Show a list of modified files within a commit

$ git show --pretty="format:" --name-only 5337804784f02a2a7c5d2cf79f5ef6a03de331fb

Diff the same file between the last 2 commits

$ git diff HEAD^^..HEAD -- main.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment