Last active
August 29, 2017 12:37
-
-
Save HSBallina/80446f5cc4d400d6b1f5010c90ca5c87 to your computer and use it in GitHub Desktop.
Git aliases with autocompletion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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