Home

Awesome

<img src="https://cdn.rawgit.com/oh-my-fish/oh-my-fish/e4f1c2e0219a17e2c748b824004c8d0b38055c16/docs/logo.svg" align="left" width="144px" height="144px"/>

git

A git aliases plugin for Oh My Fish and Fisher, based loosely on the Oh My Zsh Git Plugin.

MIT License Fish Shell Version Oh My Fish Framework Nix Package

<br/>

Install

oh-my-fish:

$ omf install https://github.com/jhillyerd/plugin-git

fisher:

$ fisher install jhillyerd/plugin-git

Nix's home-manager:

{
  # ...
  programs.fish = {
    enable = true;

    plugins = [
      {
        name = "plugin-git";
        src = pkgs.fishPlugins.plugin-git.src;
      }
    ];
  };
  # ...
}

Default branch name

plugin-git respects init.defaultBranch setting that was introduced in git 2.28. The order for resolving the default branch name is as follows:

  1. init.defaultBranch if it is set and the branch exists
  2. main if it exists
  3. master as fallback

Sample workflow

cd my-repo       # enter a git repo
gss              # check current status

.. bunch of old edits I don't want ..

gclean!!         # pristine repo!!
gcom             # checkout main/master branch
gl               # pull changes
gcb fix-bug      # create new fix-bug branch

.. edit files ..

gaa              # add (stage) all changed and new files
gc               # commit changes
gpu              # push to origin, set upstream

.. oops, edit more files ..

gcan!            # amend commit w/ all modified files, re-using message
gp!              # force push changes

.. main branch has some changes I need ..

grbom            # fetch origin and rebase on main/master

.. editing some files, but need to work on something else quickly ..

gwip             # save WIP commit of working directory for later
gfa              # fetch all branches from origin
gloga            # view log graph of all recent repo activity
gco feature      # switch to existing feature branch
gwch             # inspect what changed recently (with diffs)

.. edit lots of files ..

ga file1 file2   # add just the files I want to commit

.. hmm, will my tests pass with just these two files? ..

gtest make test  # runs 'make test' against staged changes only

.. failed! need to patch in some other changes ..

gapa             # selectively stage more changes
gtest make test
gcm "tests pass" # commit staged w/ message
gca              # commit all other modified files
gp               # push

.. back to my bugfix ..

gco fix-bug      # checkout
gunwip           # restore work in progress

Usage

Bisect

AbbreviationCommand
gbsgit bisect
gbsbgit bisect bad
gbsggit bisect good
gbsrgit bisect reset
gbssgit bisect start

Branch

AbbreviationCommand
gbgit branch -vv
gbagit branch -a -v
gbangit branch -a -v --no-merged
gbdgit branch -d
gbDgit branch -D
gbdadelete all branches merged in current HEAD
gbagelist local branches and display their age
ggsupgit branch --set-upstream-to=origin/(__git.current_branch)
grenamerename old branch to new, including in origin remote

Checkout

AbbreviationCommand
gcogit checkout
gcodgit checkout develop
gcomgit checkout (__git.default_branch)
gcbgit checkout -b

Commit

AbbreviationCommand
gcgit commit -v
gc!git commit -v --amend
gcn!git commit -v --no-edit --amend
gcagit commit -v -a
gca!git commit -v -a --amend
gcan!git commit -v -a --no-edit --amend
gcvgit commit -v --no-verify
gcavgit commit -a -v --no-verify
gcav!git commit -a -v --no-verify --amend
gcmgit commit -m
gcamgit commit -a -m
gcsgit commit -S
gscamgit commit -S -a -m
gcfxgit commit --fixup

Diff

AbbreviationCommand
gdgit diff
gdcagit diff --cached
gdsgit diff --stat
gdscgit diff --stat --cached
gdtlist changed files
gdwgit diff --word-diff
gdwcgit diff --word-diff --cached
gdtogit difftool
gdggit diff --no-ext-diff
gdvpipe git diff to view command

Flow

AbbreviationCommand
gfbgit flow bugfix
gffgit flow feature
gfrgit flow release
gfhgit flow hotfix
gfsgit flow support
gfbsgit flow bugfix start
gffsgit flow feature start
gfrsgit flow release start
gfhsgit flow hotfix start
gfssgit flow support start
gfbtgit flow bugfix track
gfftgit flow feature track
gfrtgit flow release track
gfhtgit flow hotfix track
gfstgit flow support track
gfpgit flow publish

Log

AbbreviationCommand
gcountgit shortlog -sn
glggit log --stat
glgggit log --graph
glggagit log --graph --decorate --all
glogit log --oneline --decorate --color
gloogit log --pretty=format:'%C(yellow)%h %Cred%ad %Cblue%an%Cgreen%d %Creset%s' --date=short
gloggit log --oneline --decorate --color --graph
glogagit log --oneline --decorate --color --graph --all
glomgit log --oneline --decorate --color (__git.default_branch)..
glodgit log --oneline --decorate --color develop..
glpgit log at requested pretty level
gwchgit whatchanged -p --abbrev-commit --pretty=medium

Push & Pull

AbbreviationCommand
glgit pull
gglgit pull origin (__git.current_branch)
gupgit pull --rebase
gupvgit pull --rebase -v
gupagit pull --rebase --autostash
gupavgit pull --rebase --autostash -v
glrgit pull --rebase
gpgit push
gp!git push --force-with-lease
gpogit push origin
gpo!git push --force-with-lease origin
gpvgit push --no-verify
gpv!git push --no-verify --force-with-lease
ggpgit push origin (__git.current_branch)
ggp!git push origin (__git.current_branch) --force-with-lease
gpugit push origin (__git.current_branch) --set-upstream
gpoatgit push origin --all; and git push origin --tags
ggpnppull & push origin current-branch

Rebase

AbbreviationCommand
grbgit rebase
grbagit rebase --abort
grbcgit rebase --continue
grbigit rebase --interactive
grbmgit rebase (__git.default_branch)
grbmigit rebase (__git.default_branch) --interactive
grbmiagit rebase (__git.default_branch) --interactive --autosquash
grbomgit fetch origin (__git.default_branch); and git rebase FETCH_HEAD
grbomigit fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive
grbomiagit fetch origin (__git.default_branch); and git rebase FETCH_HEAD --interactive --autosquash
grbdgit rebase develop
grbdigit rebase develop --interactive
grbdiagit rebase develop --interactive --autosquash
grbsgit rebase --skip
ggugit pull --rebase origin \(__git.current_branch\)

Remote

AbbreviationCommand
grgit remote -vv
gragit remote add
grmvgit remote rename
grpogit remote prune origin
grrmgit remote remove
grsetgit remote set-url
grupgit remote update
grvgit remote -v

Stash & Work in Progress

AbbreviationCommand
gstagit stash
gstdgit stash drop
gstlgit stash list
gstpgit stash pop
gstsgit stash show --text
gtestruns specified command against staged files only
gwipcommit a work-in-progress branch
gunwipuncommit the work-in-progress branch

Tags

AbbreviationCommand
gtsgit tag -s
gtvgit tag | sort -V
gtllist tags matching prefix

Local Files

AbbreviationCommand
gagit add
gaagit add --all
gaugit add --update
gapagit add --patch
grmgit rm
grmcgit rm --cached
grsgit restore
grssgit restore --source
grstgit restore --staged

Worktree

AbbreviationCommand
gwtgit worktree
gwtagit worktree add
gwtlsgit worktree list
gwtlogit worktree lock
gwtmvgit wortree remove
gwtprgit worktree prune
gwtulogit worktree unlock

GitLab-specific push options

AbbreviationCommand
gmrPush current branch and create a merge request from it
gmwpsSame as gmr but set the merge request to merge when the pipeline succeeds

Everything Else

AbbreviationCommand
ggit
gapgit apply
gblgit blame -b -w
gcfgit config --list
gclgit clone
gcleangit clean -di
gclean!git clean -dfx
gclean!!git reset --hard; and git clean -dfx
gcpgit cherry-pick
gcpagit cherry-pick --abort
gcpcgit cherry-pick --continue
gignoregit update-index --assume-unchanged
gignoredlist temporarily ignored files
gfgit fetch
gfagit fetch --all --prune
gfmgit fetch origin (__git.default_branch) --prune; and git merge FETCH_HEAD
gfogit fetch origin
gmgit merge
gmtgit mergetool --no-prompt
gmomgit merge origin/(__git.default_branch)
grevgit revert
grhgit reset HEAD
grhhgit reset HEAD --hard
grhpagit reset --patch
grtcd into the top of the current repository or submodule
gshgit show
gsdgit svn dcommit
gsrgit svn rebase
gsbgit status -sb
gssgit status -s
gstgit status
gsugit submodule update
gsurgit submodule update --recursive
gsurigit submodule update --recursive --init
gswgit switch
gswcgit switch --create
gunignoregit update-index --no-assume-unchanged

License

MIT © James Hillyerd et al