Skip to content

Instantly share code, notes, and snippets.

@tszpinda
Last active November 10, 2015 09:17
Show Gist options
  • Save tszpinda/4a68647b4cd184bdef26 to your computer and use it in GitHub Desktop.
Save tszpinda/4a68647b4cd184bdef26 to your computer and use it in GitHub Desktop.
git commands
#delete local branch
git branch -D bugfix
#delete remote branch
git push origin --delete bugfix
#remove unstaged files
find . -name '.gitignore' | xargs git clean -f
#remove all unstaged files and dirs
git clean -fdx
#reset only unstaged files
git checkout -- .
#change remote
git remote -v
git remote set-url origin <new url>
#git history of deleted file
git log --all -- <path-to-file>
git show <SHA> -- <path-to-file>
#sqash last 3 commits (git reset will stage all files from last 3 commits)
git reset --soft HEAD~3
git commit
#files changed in last commit
git log --name-status -1 .
#files changed in last 3 commits
git log --name-status -3 .
#show short commit info with asci graph
git log --graph --oneline --decorate
#show detailed changes in commits
git log -p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment