gpt4 book ai didi

git fetch --quiet 正在写入标准输出而不是保持沉默

转载 作者:行者123 更新时间:2023-12-05 07:43:49 26 4
gpt4 key购买 nike

git fetch --quiet &>/dev/null & 仍在写入 stdout 以询问用户名。是否有任何解决方法来存档它。

编辑:添加细节我有一个自定义脚本来显示 git 状态(bash-git-prompt 的修改版本)该脚本在后台运行上述命令。

上述命令的问题是当我 cd 到一个私有(private)仓库时,我使用 HTTP 身份验证对其进行身份验证。(出于明显的原因,我无法在 git URL 中保存用户名或密码。)我在中间收到一条烦人的消息输入命令 git fetch writing to stdout

我需要的是有什么办法可以阻止它。&> 不起作用,因为它是打印到标准输出的 git 凭据,而不是 git,正如@torek 告诉 ref 的那样.

最佳答案

2021 年的解决方案是使用 Microsoft GCM (Git-Credential-Manager-Core),以便缓存凭证。

这是一个跨平台解决方案,也适用于 Linux/Ubuntu,前提是您添加一个 credential store。 .

并确保使用 Git 2.34(2021 年第 4 季度),其中“git fetch --quiet( man ) 包括一项优化,以避免对永远不会显示的信息进行无用的计算。

参见 commit f6bb64d (2021 年 8 月 30 日)Patrick Steinhardt (pks-t) .
(由 Junio C Hamano -- gitster -- merge 于 commit 87d4aed ,2021 年 9 月 10 日)

fetch: skip formatting updated refs with --quiet

Signed-off-by: Patrick Steinhardt

When fetching, Git will by default print a list of all updated refs in a nicely formatted table.
In order to come up with this table, Git needs to iterate refs twice: first to determine the maximum column width, and a second time to actually format these changed refs.

While this table will not be printed in case the user passes --quiet, we still go out of our way and do all these steps.
In fact, we even do more work compared to not passing --quiet: without the flag, we will skip all references in the column width computation which have not been updated, but if it is set we will now compute widths for all refs.

Fix this issue by completely skipping both preparation of the format and formatting data for display in case the user passes --quiet, improving performance especially with many refs.
The following benchmark shows a nice speedup for a quiet mirror-fetch in a repository with 2.3M refs:

Benchmark #1: HEAD~: git-fetch
Time (mean ± σ): 26.929 s ± 0.145 s [User: 24.194 s, System: 4.656 s]
Range (min … max): 26.692 s … 27.068 s 5 runs

Benchmark #2: HEAD: git-fetch
Time (mean ± σ): 25.189 s ± 0.094 s [User: 22.556 s, System: 4.606 s]
Range (min … max): 25.070 s … 25.314 s 5 runs

Summary
'HEAD: git-fetch' ran
1.07 ± 0.01 times faster than 'HEAD~: git-fetch'

关于git fetch --quiet 正在写入标准输出而不是保持沉默,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43322286/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com