UtilityStack
Git Commands Cheatsheet
Showing 34 of 34 commands
Setup & Config (4)
git config --global user.name "name"
Set username
git config --global user.email "email"
Set email
git config --list
List all configuration
git init
Initialize a new repository
Basic (8)
git status
Show working tree status
git add .
Add all files to staging
git add <file>
Add specific file to staging
git commit -m "message"
Commit staged changes
git commit -am "message"
Add and commit in one step
git log
Show commit history
git log --oneline
Show compact commit history
git diff
Show unstaged changes
Branching (6)
git branch
List all branches
git branch <name>
Create new branch
git checkout <branch>
Switch to branch
git checkout -b <branch>
Create and switch to branch
git branch -d <branch>
Delete branch
git merge <branch>
Merge branch into current
Remote (7)
git clone <url>
Clone remote repository
git remote -v
List remote repositories
git remote add origin <url>
Add remote repository
git push origin <branch>
Push to remote branch
git push -u origin <branch>
Push and set upstream
git pull
Fetch and merge from remote
git fetch
Download remote changes
Undo (5)
git reset HEAD <file>
Unstage file
git checkout -- <file>
Discard changes in file
git reset --soft HEAD~1
Undo last commit, keep changes
git reset --hard HEAD~1
Undo last commit, discard changes
git revert <commit>
Create new commit that undoes changes
Stash (4)
git stash
Stash current changes
git stash pop
Apply and remove latest stash
git stash list
List all stashes
git stash drop
Delete latest stash