Reputation: 968
As an example I use this command to write a git aliases.
git config --global alias.a add
Now this means that I have to write:
git a
Which is super annoying..
I was wondering if there is a way that I can apply this aliase globally so that I only have to write:
a
This will save me from writing git..
I thought that this would work but it doesn't.
git config --global alias.a git add
Upvotes: 2
Views: 96
Reputation: 2971
To configure your terminal to support bash aliases (which people often name as Git Aliases, git shortcodes, git short commands):
nano ~/.profile
in opened file add necessary aliases at the end of file, e.g.:
alias gst='git status'
alias gc='git commit'
alias gco='git checkout'
alias gl='git pull'
alias gpom="git pull origin master"
alias gp='git push'
alias gd='git diff | mate'
alias gb='git branch'
alias gba='git branch -a'
alias del='git branch -d'
See more aliases https://gist.github.com/filidorwiese/d228588ee8023c6fdfb24c85979172ab
Save the file and restart all Terminals (including Tabs).
From now on you can write gst
instead of git status
etc.
Documentation: https://www.viget.com/articles/terminal-aliases-for-git/
BTW, What you were trying to use is Git Aliases but it always requires to write 'git ' before alias.
Upvotes: 0
Reputation: 2286
It depends on how involved you want to get, but another option is to create a globally installed Node package that essentially wraps git commands.
For example, I wrote christian-git this way. "Jesus" is the command defined in my package.json, and the index.js file is only responsible for parsing the command I entered and executing the appropriate git command.
When installed globally, "Jesus testimony" executes "git log," for example.
Might be the the most ridiculous illustration you get... but it also works.
https://github.com/alexmacarthur/christian-git
Upvotes: 0
Reputation: 29791
Use a shell alias instead, like bash aliases:
alias a="git add"
If you put that in the ~/.bashrc
file, you'll automatically have the alias available in every shell instance.
Upvotes: 5