Skip to content

Collection of useful Git shortcuts to call from Zsh.

License

Notifications You must be signed in to change notification settings

fehbari/git-shortcuts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-shortcuts Platforms Shell

What is this?

A collection of useful Git shortcuts to call from your Zsh terminal.

What does it do?

It facilitates everyday Git tasks by providing a shorter syntax and convenient functions.

Not for you?

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.

Installation

Install the latest release by following the instructions in that page.

Cheatsheet

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.

Reference

Use --help with any command to see its detailed reference, or read it below.

gadd

Stage all new and changed files.


gbase

Switch to base branch and optionally sync with remote.

Option Description
-s --sync Sync with latest changes from remote.

gbranch

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)

gcommit

Stage all changes and commit work with a message.

Usage:

gcommit "Your commit message"

gdiff

List all staged and unstaged changes.


gfetch

Fetch branches and tags, and remove outdated local references (prune).


gmerge

Merge latest from base branch into the active branch.


gpull

git pull but shorter :)


gpush

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)

grebase

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.

gsquash

Use git-squash to squash commits and sync with base branch.


gtrack

Set the upstream of branch to origin/branch.

About

Collection of useful Git shortcuts to call from Zsh.

Topics

Resources

License

Stars

Watchers

Forks

Languages