我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
我看了一段录像,里面有人
git st
git ci
去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?
当前回答
需要执行命令git config alias。在Git存储库中执行以下命令:
git config alias.ci commit
对于全局别名:
git config --global alias.ci commit
其他回答
可以为git和非git命令设置别名。这看起来像是在1.5版中添加的。在我的Mac 2.5.4版本上,git配置帮助页面的一个片段显示:
如果别名展开以感叹号作为前缀,则它将被视为shell命令。
例如,在你的全局.gitconfig文件中,你可以有:
[alias]
st = status
hi = !echo 'hello'
然后运行它们:
$ git hi
hello
$ git st
On branch master
...
需要执行命令git config alias。在Git存储库中执行以下命令:
git config alias.ci commit
对于全局别名:
git config --global alias.ci commit
这将为status创建一个别名st:
Git配置——添加别名。圣的地位
对我来说(我使用终端mac)只有当我添加.bash_profile并打开另一个选项卡来加载更改时才有效:
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"
我认为最有用的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