Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Created July 9, 2012 05:06
Show Gist options
  • Save rstacruz/3074304 to your computer and use it in GitHub Desktop.
Save rstacruz/3074304 to your computer and use it in GitHub Desktop.
# Hello, Git. Let's make you better.
alias g="git"
# Sensible git defaults:
# ----------------------
alias gadd="git add --verbose" # Make it print out the files added.
alias ggrep="git grep --color=always -I" # Colored; don't search binary files (-I).
alias gdiff="git diff --color --patch-with-stat" # Show stats of each commit; color.
alias glog="git log --color --graph --decorate --date=relative" # Color; short dates; have a small "graph" lines on the left.
alias gcommit="git commit --verbose" # When doing commit without -m, show diff in text editor.
alias gmerge="git merge --stat" # Show stats of a merge. Also consider `--no-ff`.
alias gpush="git push --set-upstream" # Auto set tracking of branches.
alias gclone="git clone --recursive" # Clone the submodules, too.
alias gstatus="git status --branch" # Also show branch name.
# Abbreviations
# -------------
alias ga=gadd
alias gg=ggrep
alias gd=gdiff
alias gl=glog
alias gc=gcommit
alias gm=gmerge
alias gst=gstatus # `gs` is for Ghostscript.
alias gsm="git submodule"
# Aliases for common arguments
# ----------------------------
alias gaa="gadd -A" # Stage everything (including deleted files)
alias gca="gcommit --amend"
alias gpr="git pull --rebase"
alias gdw="gdiff --word-diff=color" # Show word diffs.
# Extra commands
# --------------
# $ gcd
# Go to the root directory of a Git working directory.
alias gcd='cd "`git rev-parse --show-toplevel`"'
# $ gsubmoduleadd <repostiory> [<path>]
# Adds a submodule. Takes care of submodule init for you.
alias gsubmoduleadd="gcd; [ -f .gitmodules ] || git sumbodule init; git submodule add"
@victusfate
Copy link

nifty, when I'm cloning or pulling I'm never sure if it's --recurse-submodules or --recursive. Time to shut up and set some aliases :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment