Skip to content

Instantly share code, notes, and snippets.

@marcobiedermann marcobiedermann/
Last active Jan 10, 2018

What would you like to do?
Cheatsheet of git commands

Get status

git status

Add file to staging area

git add FILE

Add all files to staging area

git add .

Promt you which files to add

git add -p

Commit staged files

git commit -m "COMMIT MESSAGE"

Get branches

git branch

Delete branch

git branch -d BRANCH

Delete all branches which have been merged

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

Get remotes

git remote

Get remotes with url

git remote -v

Add remote

git remote add NAME URL

Pull changes from default

git pull

Diff unstaged changes

git diff

Diff staged changes

git diff --staged

Diff all changes

git diff HEAD

Log git history in oneline graph view

git log --oneline --decorate --all -graph

Abord merge

git merge --abort

Rebase master

git checkout BRANCH
git rebase master

Git rebase interactive

git rebase -i

Clean up local stage

git rm --cached -r .
git reset --hard
git checkout -f .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.