# Oh-My-Zsh Git Aliases Commonly used aliases from the [oh-my-zsh git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git): | Alias | Command | Description | |-------|---------|-------------| | `g` | `git` | Git | | `gst` | `git status` | Working tree status | | `ga` | `git add` | Stage files | | `gaa` | `git add -A` | Stage all changes | | `gapa` | `git add -p` | Stage interactively (patch) | | `gau` | `git add -u` | Stage modified/deleted (not new) | | `gav` | `git add -v` | Stage with verbose output | | `gc` | `git commit -v` | Commit | | `gca` | `git commit -v -a` | Commit all changes | | `gca!` | `git commit -v -a --amend` | Amend with all changes | | `gcan!` | `git commit -v -a --no-edit --amend` | Amend with all changes, keep message | | `gc!` | `git commit -v --amend` | Amend last commit | | `gcn` | `git commit -v --no-edit` | Commit, keep message | | `gcn!` | `git commit -v --no-edit --amend` | Amend, keep message | | `gco` | `git checkout` | Switch branches | | `gcb` | `git checkout -b` | Create and switch to new branch | | `gd` | `git diff` | Diff working tree | | `gds` | `git diff --staged` | Diff staged changes | | `gl` | `git pull` | Pull from remote | | `gpra` | `git pull --rebase --autostash` | Pull with rebase and autostash | | `gprav` | `git pull --rebase --autostash -v` | Pull with rebase, autostash, verbose | | `gp` | `git push` | Push to remote | | `gpf` | `git push --force-with-lease --force-if-includes` | Safe force push (prefer this) | | `gpf!` | `git push --force` | Force push (dangerous) | | `grb` | `git rebase` | Rebase | | `grbi` | `git rebase -i` | Interactive rebase | | `grba` | `git rebase --abort` | Abort rebase | | `grbc` | `git rebase --continue` | Continue rebase | | `grbs` | `git rebase --skip` | Skip current rebase commit | | `glog` | `git log --oneline --decorate --graph` | Pretty log | | `gloga` | `git log --oneline --decorate --graph --all` | Pretty log (all branches) | | `gwip` | `git add -A; git rm $(git ls-files --deleted) 2>/dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"` | Quick WIP commit (all changes) | | `gunwip` | `git rev-list --max-count=1 --format="%s" HEAD \| grep -q "\--wip--" && git reset HEAD~1` | Undo last WIP commit (keeps changes unstaged) | | `gwipe` | `git reset --hard && git clean --force -df` | Nuke all changes (dangerous) | | `gsta` | `git stash push` | Stash changes | | `gstall` | `git stash --all` | Stash everything (incl. ignored) | | `gstu` | `git stash --include-untracked` | Stash incl. untracked files | | `gstaa` | `git stash apply` | Apply stash (keep in list) | | `gstp` | `git stash pop` | Pop stash | | `gstl` | `git stash list` | List stashes | | `gstd` | `git stash drop` | Drop a stash | | `gstc` | `git stash clear` | Clear all stashes | | `gb` | `git branch` | List branches | | `gba` | `git branch -a` | List all branches (incl. remote) | | `gbd` | `git branch -d` | Delete branch (soft) | | `gbD` | `git branch -D` | Delete branch (force) | | `gbg` | `git branch -vv \| grep gone` | List branches gone from remote | | `gbgd` | (see [[Branch Cleanup]]) | Delete gone branches (soft) | | `gbgD` | (see [[Branch Cleanup]]) | Delete gone branches (force) | ## Workflows ### WIP commits (`gwip` / `gunwip`) Quick save-and-restore for work in progress — e.g. before switching branches or at end of day: ```bash gwip # snapshot everything into a WIP commit # ... switch branches, do other work ... gco my-branch gunwip # undo the WIP commit, changes back in working tree ``` `gwip` stages everything (including untracked), commits with `--no-verify` and message `--wip-- [skip ci]`. `gunwip` only resets if the last commit is a WIP commit — safe to run anytime. ### Branch cleanup (`gbg` / `gbgd` / `gbgD`) After PRs are merged and branches deleted on the remote: ```bash git fetch --prune # remove stale remote-tracking refs gbg # list local branches marked "gone" gbgd # delete them (soft — fails if unmerged) gbgD # delete them (force) ``` See [[Branch Cleanup]] for manual equivalents.