Skip to content

Instantly share code, notes, and snippets.

@matthewblewitt
Last active May 1, 2019 12:56
Show Gist options
  • Save matthewblewitt/af26587f8443368af0089c258f3370e9 to your computer and use it in GitHub Desktop.
Save matthewblewitt/af26587f8443368af0089c258f3370e9 to your computer and use it in GitHub Desktop.
GIT cheatsheet

Git Cheatsheet

What changed in the last commit

git show --name-status

Log one line

git log --oneline

Revert to the HEAD of the branch and lose all changes

git reset --hard HEAD

View local and remote branches

git branch
git branch -a

Delete local and remote branches

git branch -D <branch_name>
git push <remote_name> --delete <branch_name>

Push branch to remote

git push -u <remote_name> <branch_name>

Show your Git user details

git config --list

Unstage files

git reset -- <filePath>

Add every file expect

git add -u
git reset -- <file_name>

Checkout new local branch from origin

git checkout -b test origin/test

Remove all your local git branches but keep master

git branch | grep -v "master" | xargs git branch -D 

Diff of git commit with its parent

git diff <commit>^!

git tag release18 49c77e7fad5b75b6cdf3e366a15ebeff6b4c53cc -f

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