Skip to content

Instantly share code, notes, and snippets.

@HSBallina
Last active Aug 29, 2017
Embed
What would you like to do?
Git aliases with autocompletion
#Add this to your home as .profile (or any other script to fit your needs) and download the git-completion.bash
#file (save as .git-completion.bash).
echo "Hello World!
"
alias g="git"
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias gf='git fetch'
alias gg='gf && gp'
alias gm="git merge"
alias go="git checkout"
alias gp="git pull --rebase"
alias gs='git status '
echo "Available aliases:
g git
ga git add
gb git branch
gc git commit
gd git diff
gf git fetch
gg gf && gp
gm git merge
go git checkout
gp git pull --rebase
gs git status
"
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
# Add git completion to aliases
__git_complete g __git_main
__git_complete ga _git_add
__git_complete gb _git_branch
__git_complete gc _git_commit
__git_complete gd _git_diff
__git_complete gm _git_merge
__git_complete go _git_checkout
__git_complete gp _git_pull
__git_complete gs _git_status
echo "Autocompletion loaded
"
else
echo "Failed to load autocomplete. Couldn't find ~/.git-completion.bash"
echo "Can be found here: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash"
fi
echo "Have a nice day!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment