在本地克隆 git 存储库后,我想将分支切换到“ABCD”。
$ git branch -a
* master
remotes/origin/ABCD
remotes/origin/HEAD -> origin/master
remotes/origin/master
$ git checkout origin/ABCD #### <- Here is the problem!
Note: checking out 'origin/ABCD'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at f2bf54a... Clean up README.md
当我在之后按 Tab 时git checkout
,由于某种原因,自动补全总是以以下开头origin/
,因此会出现警告消息分离头状态。
我怎样才能让自动完成不是在开头添加“来源”?
答案1
我找到了一个很棒的插件,zsh
您可以使用。如果您正在使用oh-my-zsh
then 它被称为gitfast
或者如果只是使用zsh
then 您可以按照他的博客文章上的说明进行操作。
正如作者所详述的,实际上存在相当多的git
完成问题,他正在努力解决所有这些问题。这个问题现在的工作方式与 bash 中的工作方式类似。
https://felipec.wordpress.com/2013/07/31/how-i-fixed-git-zsh-completion/
要启用oh-my-zsh
编辑.zshrc
并更改插件行以添加 gitfast,如下所示
plugins=(git gitfast)