Git Cheatsheet

The most used git commands, ready to copy and paste.

Fill in your values

Enter your own values below and every matching command updates automatically.

Clone a repository

git clone <Repository URL>

Check the status of your working directory

git status

Stage a file for commit

git add <File Name>

Stage all changes

git add .

Commit staged changes

git commit -m "<Commit Message>"

View a condensed commit history

git log --oneline

Create and switch to a new branch

git checkout -b <Branch Name>

Switch to an existing branch

git checkout <Branch Name>

List all local branches

git branch

Push a branch to the remote and track it

git push -u origin <Branch Name>

Pull the latest changes from the remote

git pull

Merge a branch into the current branch

git merge <Branch Name>

Stash your uncommitted changes

git stash

Re-apply your most recent stash

git stash pop

Discard local changes to a file

git checkout -- <File Name>

Delete a local branch

git branch -d <Branch Name>

Show configured remotes

git remote -v

Undo the last commit but keep the changes staged

git reset --soft HEAD~1

No commands match your search.