$ 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.
[alias]
st = status
ci = commit
co = checkout
br = branch
unstage = reset HEAD --
last = log -1 HEAD
此外,如果您使用bash,我建议通过将git-completion.bash复制到您的主目录并从您的~/.bashrc中获取它来设置bash完成。(我相信我从progit在线书籍中学到了这一点。)在Mac OS X上,我使用以下命令完成了此操作:
# 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
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'
[user]
name = my name
email = me@example.com
[core]
editor = vi
[alias]
aa = add --all
bv = branch -vv
ba = branch -ra
bd = branch -d
ca = commit --amend
cb = checkout -b
cm = commit -a --amend -C HEAD
ci = commit -a -v
co = checkout
di = diff
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
mm = merge --no-ff
st = status --short --branch
tg = tag -a
pu = push --tags
un = reset --hard HEAD
uh = reset --hard HEAD^
[color]
diff = auto
status = auto
branch = auto
[branch]
autosetuprebase = always
$ git co # use git co instead of git checkout
$ git ci # use git ci instead of git commit
$ git st # use git st instead of git status
$ git br # use git br instead of git branch
g a . // git add .
g b other-branch // git branch other-branch
g c "made some changes" // git commit -m "made some changes"
g co master // git checkout master
g d // git diff
g f // git fetch
g i // git init
g m hotfix // git merge hotfix
g pll // git pull
g psh // git push
g s // git status
alias gst="git status"
alias gd="git diff"
alias gl="git log"
alias gco="git commit"
alias gck="git checkout"
alias gl="git pull"
alias gpom="git pull origin master"
alias gp="git push"
alias gb="git branch"
$ git st
$ git co
$ git br
$ git ci
$ git last
$ git unstage <file | dir>
一切都会变成:
$ cat ~/.gitconfig
[user]
name = Sample User
email = sample@gmail.com
[core]
filemode = false
compression = 1
quotepath = off
ignorecase = false
[color]
ui = auto
[alias]
co = checkout
br = branch
ci = commit
st = status
last = log -1 HEAD
unstage = reset HEAD --
alias gs='git status'
alias gp='git pull'
alias gph='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -m'
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'
alias gfo='git fetch origin'