我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
当前回答
一行设置
$ git config --global alias.co checkout && git config --global alias.br branch && git config --global alias.ci commit && git config --global alias.st status && git config --global alias.unstage 'reset HEAD --' && git config --global alias.last 'log -1 HEAD'
用法:
$ 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 --
希望能快点。
其他回答
这将为status创建一个别名st:
Git配置——添加别名。圣的地位
基本上,您只需要在~/.gitconfig中添加行即可
[alias]
st = status
ci = commit -v
或者你可以使用git config alias命令:
$ git config --global alias.st status
在unix中,如果别名中有空格,则使用单引号:
$ git config --global alias.ci 'commit -v'
在windows中,如果别名有空格或命令行参数,则使用双引号:
c:\dev> git config --global alias.ci "commit -v"
alias命令甚至接受函数作为参数。看看别名。
这招对我很管用:
bco = "!f(){ git branch ${1} && git checkout ${1}; };f"
on:
$ git --version
git version 1.7.7.5 (Apple Git-26)
我认为最有用的gitconfig是这样的,我们总是在git中使用20%的函数,你可以试试“g ll”,它是惊人的,细节:
[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 config alias。在Git存储库中执行以下命令:
git config alias.ci commit
对于全局别名:
git config --global alias.ci commit