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

git st
git ci

去工作。当我这样做时,我得到一个错误,问我是否我指的是其他东西。 作为一个新手,我想知道你要怎么做才能完成这件事?


当前回答

如果您想要~/。Gitconfig选项,可以更深入地挖掘,另一个选项是通过将它们包装在全局节点包中来编写完全自定义的git命令。

在你的包裹里。Json,您将定义根命令(例如:gt),然后筛选特定的命令以执行正确的git命令。例如,git checkout my-branch可以是gt co mybranch。

npm上的“christian-git”包使用这个方法:https://github.com/alexmacarthur/christian-git

其他回答

我创建了别名dog来显示日志图:

git config --global alias.dog "log --all --decorate --oneline --graph"

使用方法如下:

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

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

git config alias.ci commit

对于全局别名:

git config --global alias.ci commit

这招对我很管用:

bco = "!f(){ git branch ${1} && git checkout ${1}; };f"

on:

$ git --version

git version 1.7.7.5 (Apple Git-26)

你可以使用git的配置设置自定义的git别名。语法如下:

git config --global alias.<aliasName> "<git command>"

例如,如果你需要一个别名来显示有合并冲突的文件列表,运行:

git config --global alias.conflicts "diff --name-only --diff-filter=U"

现在你只能使用"conflicts"来使用上面的命令:

git conflicts
# same as running: git diff --name-only --diff-filter=U