CONFIG
git config --global user.name "Your Name" git config --global user.email you@example.com
ssh-keygen -t ed25519 -C "you@example.com"
ssh-add -K ~/.ssh/id_ed25519
git config --list --show-origin
INITIALIZE OR CLONE
git init
git clone git@example.com:user/repo.git
CHECK STATUS
git status
git diff
git diff [a]...[b]
STAGE AND UNSTAGE
git add .
git add [file]
git add -p [file]
git rm --cached [file]
git mv [old] [new]
git clean -fd
COMMIT CHANGES
git commit
git commit -a
git commit --amend
SAVE AND RESTORE
git stash
git stash pop
Apply the most recent stash to your working tree and remove it
git stash drop
git stash list
SHOW HISTORY
git log
git log --oneline
git log --follow [file]
git blame [file]
MANAGE BRANCHES
git branch -a
git branch [name]
git checkout [branch]
git checkout -t [remote/branch]
git branch -d [branch]
git branch -dr [remote/branch]
MANAGE TAGS
git tag [name]
git tag -d [name]
git push -d [remote] [tagname]
MANAGE REMOTES
git remote -v
git remote show [remote]
git remote add [name] [url]
FETCH CHANGES
git fetch [remote]
Fetch all changes from the remote, but do not merge them into HEAD
git pull [remote] [branch]
PUBLISH CHANGES
git push [remote] [branch]
git push -u [remote] [branch]
Push changes from your local HEAD to a remote branch and track it
git push --tags
MERGE AND REBASE
git merge [branch]
git rebase [branch]
UNDO
git reset [commit]
git reset --hard
git reset --hard [commit]
git checkout HEAD [file]
git revert [commit]
FIND BUGS
Use binary search to find the commit that introduced a bug.git bisect start git bisect good [commit] git bisect bad [commit]
VERIFY SIGNATURES
git verify-commit [commit]
git verify-tag [tag]
EXPORT
Create an archive of your repositorygit archive --format zip HEAD > [archive.zip]