我倾向于使用较长的git分支名称(例如,step110_create_search_engine_to_replace_google).
在checkout/commit语句中,我应该如何简单地将其称为step110?
发布于 2012-03-04 06:46:45
如果您使用的是类Unix系统(Linux、Mac等),那么contrib/complete/git-completion.bash bash自动完成规则集将允许您自动完成git命令(您可以输入git checkout step110<tab>,您的shell将自动完成分支名称)。
要激活它,请执行以下操作:
如果你有git源代码,在contrib/complete/中有一个git-completion.bash文件。将其放在安全的地方(如~/.git-completion),然后将以下行添加到~/.bashrc文件中:source ~/.git-completion。重新启动shell会话或运行source ~/.git-completion使其在当前shell会话中运行。
如果你足够幸运地使用zsh而不是bash,我知道oh-my-zsh有git自动补全插件(没有oh-my-zsh我不知道如何激活它们)。
资料来源:
发布于 2012-06-15 09:15:16
下面是我是如何在OS X上安装它的。
首先检查它是否在您的本地系统上。似乎是MacPorts和Homebrew为你下载的。
$ find / -name "git-completion.bash"否则,下载它...
$ wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion如果您没有wget,可以使用Homebrew或使用cURL轻松安装它。
$ vim ~/.profile...or是您选择的编辑器。
然后添加..。
source ~/.git-completion如果您的自动完成功能不能自动工作...
$ source ~/.profile然后你就有了...and自动补全。
发布于 2014-07-01 17:35:46
尝试此别名:
cb = "!checkoutbranch() { local branches=`git branch | grep -i $1 | tr -d '* '`; if [[ `echo \"$branches\" | wc -l | tr -d ' '` != 1 ]]; then echo \"Matched multiple branches:\"; git branch | grep --color -i $1; exit 1; fi; git checkout $branches; }; checkoutbranch"查看develop分支:
git cb dev--编辑
https://stackoverflow.com/questions/9550447
复制相似问题