我看了一段录像,里面有人

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 --

希望能快点。

其他回答

这里给出了别名。即使这里有很好的答案,我加上这个是因为 它在Windows和Linux中有所不同

$ 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.

windows的另一种可能是在一个目录中填满含有快捷方式的.bat文件。文件的名称就是要使用的快捷方式。只需将该目录添加到您的PATH环境变量中,您就可以在cmd窗口中使用所有的快捷方式。

例如(gc.bat):

git commit -m %1

在控制台中执行如下命令:

gc "changed stuff"

我添加这个作为答案的原因是,当使用这个时,你不局限于git…只有命令。

需要执行命令git config alias。在Git存储库中执行以下命令:

git config alias.ci commit

对于全局别名:

git config --global alias.ci commit
alias s="git status"

你的食指会原谅你这辈子给它带来的所有痛苦。