I saw a screencast where someone had gotten
git st
git ci
to work. When I do it I get an error asking me if I meant something else.
Being a git newb, I need to know what you have to do to get this done?
I saw a screencast where someone had gotten
git st
git ci
to work. When I do it I get an error asking me if I meant something else.
Being a git newb, I need to know what you have to do to get this done?
Basically you just need to edit .gitconfig to read
[alias] st = status ci = commit -v
Or you can use the git config alias command
git config --global alias.ci commit
the alias command even accepts functions as parameters
take a look at aliases
This will create an alias st
for status
:
git config --add alias.st status
You need the git config alias
command. Execute the following in a Git repository:
git config alias.ci commit
For global alias:
git config --global alias.ci commit
$ git update git: 'update' is not a git command. See 'git --help'. Did you mean this? update-ref $ git config --global alias.update 'pull -v' $ git update From git://git.kernel.org/pub/scm/git/git = [up to date] html -> origin/html = [up to date] maint -> origin/maint = [up to date] man -> origin/man = [up to date] master -> origin/master = [up to date] next -> origin/next = [up to date] pu -> origin/pu = [up to date] todo -> origin/todo Already up-to-date.
As others have said the appropriate way to add git aliases is in your global .gitconfig
file either by editing ~/.gitconfig
or by using the git config --global alias.<alias> <git-command>
command
Below is a copy of the alias section of my ~/.gitconfig
file:
[alias]
st = status
ci = commit
co = checkout
br = branch
unstage = reset HEAD --
last = log -1 HEAD
Also, if you're using bash, I would recommend setting up bash completion by copying git-completion.bash
to your home directory and sourcing it from your ~/.bashrc
. (I believe I learned about this from the Pro Git online book.) On Mac OS X, I accomplished this with the following commands:
# Copy git-completion.bash to home directory
cp usr/local/git/contrib/completion/git-completion.bash ~/
# Add the following lines to ~/.bashrc
if [ -x /usr/local/git/bin/git ]; then
source ~/.git-completion.bash
fi
Note: The bash completion will work not only for the standard git commands but also for your git aliases.
Finally, to really cut down on the keystrokes, I added the following to my ~/.bash_aliases
file, which is sourced from ~/.bashrc
:
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='git log --pretty=format:"%h %s" --graph'