si:git
Git Shortcuts
Git
By EZ4Code Team
Basic
7| Shortcut | Description | Platform |
|---|---|---|
| git init | Initialize a repo | all |
| git clone <url> | Clone a repo | all |
| git status | Show working tree status | all |
| git add <file> | Stage a file | all |
| git commit -m 'msg' | Commit staged changes | all |
| git log | Show commit history | all |
| git diff | Show unstaged changes | all |
Branching
7| Shortcut | Description | Platform |
|---|---|---|
| git branch | List branches | all |
| git branch <name> | Create branch | all |
| git checkout <branch> | Switch branch | all |
| git checkout -b <name> | Create & switch branch | all |
| git switch <branch> | Switch branch (newer) | all |
| git merge <branch> | Merge branch into current | all |
| git branch -d <name> | Delete branch | all |
Staging
7| Shortcut | Description | Platform |
|---|---|---|
| git add . | Stage all changes | all |
| git add -p | Stage hunks interactively | all |
| git reset <file> | Unstage a file | all |
| git reset | Unstage everything | all |
| git restore --staged <f> | Unstage (newer) | all |
| git stash | Stash changes | all |
| git stash pop | Apply last stash | all |
Remote
6| Shortcut | Description | Platform |
|---|---|---|
| git remote -v | List remotes | all |
| git remote add <n> <url> | Add remote | all |
| git fetch | Fetch from remote | all |
| git pull | Fetch & merge | all |
| git push | Push commits | all |
| git push -u origin <b> | Push & set upstream | all |
Advanced
7| Shortcut | Description | Platform |
|---|---|---|
| git rebase <branch> | Rebase onto branch | all |
| git rebase -i HEAD~3 | Interactive rebase | all |
| git reset --hard HEAD | Discard all changes | all |
| git revert <commit> | Revert a commit | all |
| git cherry-pick <c> | Apply a commit elsewhere | all |
| git reflog | Show reference log | all |
| git tag <name> | Create tag | all |