Additions and tweaks to the Git CLI.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
git-add
git-addi
git-addn
git-addr
git-addselected
git-addu
git-adduntracked
git-adduu
git-alias
git-annotate-contained-command
git-applycheck
git-applyr
git-applyrcheck
git-archivebr
git-archivelocalbr
git-archivelocalbrc
git-autostash
git-base-command
git-br
git-bra
git-brc
git-brname
git-browse
git-cat
git-cheat
git-checkout-head
git-cherrymerge
git-cherrypicks
git-churn
git-clonecommand
git-cob
git-cobr
git-commit
git-commita
git-commitfor
git-commitid
git-commitidentical
git-confighelp
git-conflicts
git-conflictwipe
git-contained-command
git-contains
git-coo
git-cot
git-createlocalbr
git-credit
git-cuu
git-datediff
git-dc
git-desc
git-describe-tag
git-describe-version
git-diffuntil
git-diffuntill
git-dirty
git-discrepancylog
git-dl
git-dp
git-dpl
git-echo
git-editstage
git-equals
git-existsbr
git-existsremote
git-fetchdate
git-find-blob
git-fixup
git-glog
git-hardreset
git-ident-update
git-inout
git-inside
git-lastmine
git-lci
git-lcl
git-lghighlight
git-lgi
git-lgmine
git-lgv
git-lhurl
git-lll
git-lllbrurl
git-lllhurl
git-localbr
git-localbrcdo
git-localbrdo
git-log
git-logi
git-logv
git-ls
git-lsprivate
git-mergelocalbr
git-mergelocalbrc
git-mergesummary
git-mergeto
git-mine-command
git-oadd
git-oarchivebr
git-ocreatelocalbr
git-oldeletebr
git-olrenamebr
git-onelinelog
git-oprune
git-opublish
git-orig-ref
git-parse-last-remotebr-argument
git-pickaxe
git-prune
git-pushall
git-pushdate
git-rbcu
git-rbfixup
git-rbr
git-rco
git-rcolatest
git-rcolatestc
git-rebaselocalbr
git-reintegrate
git-reintegrateto
git-remotebr
git-remoterenamebr
git-remotes
git-remoteurl
git-rerere
git-reset-to-tracked
git-rev-branch-remotebr-command
git-rev-fetch-command
git-rev-range
git-rev-range-incoming
git-rev-range-outgoing
git-rev-range-this-branch
git-rev-remote-command
git-rev-tracked-command
git-revert
git-rmprivate
git-rtrack
git-sdiff
git-sh
git-shortblame
git-showfiles
git-stash-pop-to-dirty
git-stash-to-branch
git-stashi
git-sti
git-sync
git-system-setup
git-tag-version
git-tagtype
git-timestamp
git-today-command
git-tracks
git-ucatchup
git-unapply-index
git-undo-rerere
git-uopush
git-up
git-updatedate
git-uptodate
git-upull
git-upush
git-urebaselocalbr
git-urestore
git-uup
git-uwipem
git-uwipen
git-whocontributed
git-whois
git-whoowns
git-wipe
git-wips
git-wrapper
git-writebackup-import
git-writebackup-ingo-import
git-wtf
gitcheats-flow.md
gitcheats-prompt.md
gitcheats.md
gitconfig
gitproxy
hub-cheat
hub-url
hubcheats-vimdev.md
hubcheats.md
ingo-extract-version-message

README.md

Git CLI extensions

These are some personal aliases, shortcuts, and extensions that make (my) work with the Git distributed version control tool easier and faster. Some of them may be specific to my environment and workflow, but maybe someone finds a valuable nugget in there.

Installation

Download all / some selected extensions (note that some have dependencies, though) and put them somewhere in your PATH. You can then invoke them via git-SUBCOMMAND; those commands that don't override built-in ones or have case differences can also be invoked via git SUBCOMMAND (space instead of hyphen!).

Additionally, the gitconfig supplies many aliases and shortcuts. You can mix and match those within your own .gitconfig, or import all of it via the following fragment in there:

[include]
        path = PATH/TO/git-extensions/gitconfig

Optionally, use the following (Bash, but should also work in Korn shell and Dash) shell function (e.g. in your .bashrc) to transparently invoke the extensions in the same way as the built-in Git commands, via git SUBCOMMAND:

# Git supports aliases defined in .gitconfig, but you cannot override Git
# builtins (e.g. "git log") by putting an executable "git-log" somewhere in the
# PATH. Also, git aliases are case-insensitive, but case can be useful to create
# a negated command (gf = grep --files-with-matches; gF = grep
# --files-without-match). As a workaround, translate "X" to "-x".
git() {
    typeset -r gitAlias="git-$1"
    typeset -r gitCommand="$(which git)"
    if [ $# -eq 0 ]; then
        git ${GIT_DEFAULT_COMMAND:-st}
    elif type ${BASH_VERSION:+-t} "$gitAlias" >/dev/null 2>&1; then
        shift
        eval $gitAlias '"$@"'
    elif [ "$1" = "${1#-}" ] && expr "$1" : '.*[[:upper:]]' >/dev/null; then
        # Translate "X" to "-x" to enable aliases with uppercase letters.
        translatedAlias=$(echo "$1" | sed -e 's/[[:upper:]]/-\l\0/g')
        shift
        "$gitCommand" "$translatedAlias" "$@"
    else
        "$gitCommand" "$@"
    fi
}

Here is a variant that also adds support for the hub extension:

# Git supports aliases defined in .gitconfig, but you cannot override Git
# builtins (e.g. "git log") by putting an executable "git-log" somewhere in the
# PATH. Also, git aliases are case-insensitive, but case can be useful to create
# a negated command (gf = grep --files-with-matches; gF = grep
# --files-without-match). As a workaround, translate "X" to "-x".
# Add support for the "hub" extension. As this messes with the completion for
# git, anyway, follow their advice and alias git=hub (adapted to my wrapper).
git() {
    typeset -r gitAlias="git-$1"
    typeset -r gitCommand="$(which hub || which git)"
    if [ $# -eq 0 ]; then
        git ${GIT_DEFAULT_COMMAND:-st}
    elif type ${BASH_VERSION:+-t} "$gitAlias" >/dev/null 2>&1; then
        shift
        eval $gitAlias '"$@"'
    elif [ "$1" = "${1#-}" ] && expr "$1" : '.*[[:upper:]]' >/dev/null; then
        # Translate "X" to "-x" to enable aliases with uppercase letters.
        translatedAlias=$(echo "$1" | sed -e 's/[[:upper:]]/-\l\0/g')
        shift
        "$gitCommand" "$translatedAlias" "$@"
    else
        "$gitCommand" "$@"
    fi

}

The following function also allows extending the hub command (in a different way than what the forwarded-to git command would offer, e.g. to have both git-cheat and hub-cheat):

hub() {
    typeset -r hubAlias="hub-$1"
    if [ $# -eq 0 ]; then
        hub ${HUB_DEFAULT_COMMAND:-st}
    elif type ${BASH_VERSION:+-t} "$hubAlias" >/dev/null 2>&1; then
        shift
        eval $hubAlias '"$@"'
    else
        command hub "$@"
    fi
}