在Git Bash中禁用远程分支的自动完成? [英] Disable auto-completion of remote branches in Git Bash?

查看:90
本文介绍了在Git Bash中禁用远程分支的自动完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与几千个(远程)分支机构合作开发一个相当大的git仓库。我习惯于在控制台(在这种情况下使用Git Bash)使用自动完成(使用[TAB]),所以我也无意识地为git命令做了这个。



如我会输入

  git结帐任务[TAB] 

,其结果是控制台经常停顿数分钟。有没有办法限制自动完成到本地分支?

使用Git 2.13(2017年第2季度),您可以禁用(一些)分支完成。

  git checkout --no-guess ... 
#或
export GIT_COMPLETION_CHECKOUT_NO_GUESS = 1

请参阅 commit 60e71bb (2017年4月21日)作者: Jeff King peff

(由 Junio C Hamano - gitster - commit b439747 ,2017年5月1日)



contrib / completion / git-completion.bash 现在:


您可以设置以下环境变量来影响完成例程的行为:

pre $ G $ C $ G $ G $ b

设置为1时,不要在 git-checkout中包含DWIM建议
完成(例如,当origin / foo存在时完成foo)。

注意: DWIM是 D W 帽子的缩写一个系统试图预测用户打算做什么,自动纠正微不足道的错误,而不是盲目地执行用户明确但可能不正确的输入。
$ b


完成:可选择禁用结帐DWIM



完成后 git checkout 的分支名称,我们还完成了可能触发DWIM行为的远程分支名称。根据您的工作流程和项目,这可能很方便或烦人。



例如,我的克隆 gitster.git 包含74个本地 jk / * 分支,但原点包含另一个分支147.

当我想结帐本地分支但不能相当记住名字,标签完成显示我251条目。更糟糕的是,对于一个已经被pu拾取的话题,上游分支名称很可能与我的相似,导致我选错了一个并意外创建一个新分支的概率很高。







注意:pick up for pu:参见 git.git 中的烹饪内容: / p>


前缀为' - '的提交仅在' pu '(建议的更新),而以' + '作为前缀的提交位于' next

这是 Git Workflow毕业程序


pu (提议的更新)是一个集成分支,用于那些尚未完全准备好的事物。






< blockquote>

此修补程序为用户提供了一种方法,告知完成
代码不要包含用于结帐的DWIM建议。

这可以通过键入以下命令完成: / p>

  git checkout --no-guess jk /< TAB> 

但这很麻烦。

当然,不利的一面是,当您执行操作DWIM行为时,您不再获得完成支持。

但是根据你的工作流程,这可能不是一个很大的损失(例如,在git.git中,我更愿意分离,所以我会输入 git checkout origin / jk /< TAB> )。


I'm working on a fairly large git repo with a couple of thousand (remote) branches. I am used to using auto-completion (using [TAB]) in the console (Git Bash in that case), so I unconsciously do that for git commands, too.

e.g. I'd type

git checkout task[TAB]

with the effect that the console stalls for often minutes. Is there a way to limit auto-completion to local branches only?

解决方案

With Git 2.13 (Q2 2017), you can disable (some of) the branch completion.

git checkout --no-guess ...
# or:
export GIT_COMPLETION_CHECKOUT_NO_GUESS=1

See commit 60e71bb (21 Apr 2017) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit b439747, 01 May 2017)

As documented in contrib/completion/git-completion.bash now:

You can set the following environment variables to influence the behavior of the completion routines:

GIT_COMPLETION_CHECKOUT_NO_GUESS

When set to "1", do not include "DWIM" suggestions in git-checkout completion (e.g., completing "foo" when "origin/foo" exists).

Note: DWIM is short for Do What I Mean, where a system attempts to anticipate what users intend to do, correcting trivial errors automatically rather than blindly executing users' explicit but potentially incorrect inputs.

completion: optionally disable checkout DWIM

When we complete branch names for "git checkout", we also complete remote branch names that could trigger the DWIM behavior. Depending on your workflow and project, this can be either convenient or annoying.

For instance, my clone of gitster.git contains 74 local "jk/*" branches, but origin contains another 147.
When I want to checkout a local branch but can't quite remember the name, tab completion shows me 251 entries. And worse, for a topic that has been picked up for pu, the upstream branch name is likely to be similar to mine, leading to a high probability that I pick the wrong one and accidentally create a new branch.


Note: "picked up for pu": see a What's cooking in git.git: it starts with:

Commits prefixed with '-' are only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'.

This is part of the Git Workflow Graduation process.

pu (proposed updates) is an integration branch for things that are not quite ready for inclusion yet


This patch adds a way for the user to tell the completion code not to include DWIM suggestions for checkout.
This can already be done by typing:

git checkout --no-guess jk/<TAB>

but that's rather cumbersome.

The downside, of course, is that you no longer get completion support when you do want to invoke the DWIM behavior.
But depending on your workflow, that may not be a big loss (for instance, in git.git I am much more likely to want to detach, so I'd type "git checkout origin/jk/<TAB>" anyway).

这篇关于在Git Bash中禁用远程分支的自动完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆