A collection of useful Git shortcuts to call from your Zsh terminal.
It facilitates everyday Git tasks by providing a shorter syntax and convenient functions.
These shortcuts were created to help my workflow. Most of them chain multiple Git commands in a way that saves me time. If it doesn't apply to your workflow, feel free to fork or tweak locally so it's useful to you.
Install the latest release by following the instructions in that page.
Type g --help
to access this list at any time.
Command | Options | Description |
---|---|---|
gadd |
Stage all new and changed files. | |
gbase |
-s |
Switch to base branch and optionally sync with remote. |
gbranch |
-n -p -d -c |
Switch to or perform actions on your branches. |
gcommit |
Stage all changes and commit work with a message. | |
gdiff |
List all staged and unstaged changes. | |
gfetch |
Fetch branches and tags, and remove outdated local references. | |
gmerge |
Merge latest from base branch into the active branch. | |
gpull |
git pull but shorter :) | |
gpush |
-f |
Push changes from active branch and track remote. |
grebase |
-a -c -s |
Rebase current branch onto base branch. |
gsquash |
Use git-squash to squash commits and sync with base branch. | |
gtrack |
Set the upstream of branch to origin/branch. |
Use --help
with any command to see its detailed reference, or read it below.
Stage all new and changed files.
Switch to base branch and optionally sync with remote.
Option | Description |
---|---|
-s --sync |
Sync with latest changes from remote. |
Switch to or perform actions on your branches.
Basic use:
Switch to local your/branch-name:
gbranch your/branch-name
Use with options:
gbranch [--options] your/branch-name
Option | Description |
---|---|
-n --new |
Create and switch to a new branch, based on the latest base branch. |
-n -p --new --parent |
Create and switch to a new branch, based on the current branch (parent). |
-d --delete |
Delete a local branch. |
-c --clean |
Cleanup. Delete all local branches except for base branch. Dangerous operation, requires confirmation (y/n) |
Stage all changes and commit work with a message.
Usage:
gcommit "Your commit message"
List all staged and unstaged changes.
Fetch branches and tags, and remove outdated local references (prune).
Merge latest from base branch into the active branch.
git pull but shorter :)
Push changes from active branch and track remote.
Option | Description |
---|---|
-f --force |
Force push branch. Never do it on a shared branch! Dangerous operation, requires confirmation (y/n) |
Rebase current branch onto base branch.
Option | Description |
---|---|
-a --abort |
Undo rebase with conflicts. |
-c --continue |
Continue rebase after fixing conflicts. |
-s --skip |
Skip the current patch with conflicts. |
Use git-squash to squash commits and sync with base branch.
Set the upstream of branch to origin/branch.