Skip to content

Instantly share code, notes, and snippets.

@marcobiedermann
Last active June 25, 2023 13:47
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcobiedermann/667edd6272c195354882c7f1a6b0f659 to your computer and use it in GitHub Desktop.
Save marcobiedermann/667edd6272c195354882c7f1a6b0f659 to your computer and use it in GitHub Desktop.
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 .
@skwidhubz
Copy link

This is great, thank you.

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