Git:将 'git clone' 输出打印到文件中并删除进度子状态行

标签 git

我想将 git clone 输出打印到文件中。

该文件应具有与终止进程后控制台输出相同的内容。

例如

Cloning into 'repo'...
remote: Counting objects: 8, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 8 (delta 1), reused 0 (delta 0)
Receiving objects: 100% (8/8), done.
Resolving deltas: 100% (1/1), done.
Checking connectivity... done

这将是所需的输出。

不幸的是,我得到了单一进度状态的后续行:

Cloning into 'repo'...
remote: Counting objects: 8, done.[K
remote: Compressing objects:  16% (1/6)   [K
remote: Compressing objects:  33% (2/6)   [K
remote: Compressing objects:  50% (3/6)   [K
remote: Compressing objects:  66% (4/6)   [K
remote: Compressing objects:  83% (5/6)   [K
remote: Compressing objects: 100% (6/6)   [K
remote: Compressing objects: 100% (6/6), done.[K
remote: Total 8 (delta 1), reused 0 (delta 0)[K
Receiving objects:  12% (1/8)   
Receiving objects:  25% (2/8)   
Receiving objects:  37% (3/8)   
Receiving objects:  50% (4/8)   
Receiving objects:  62% (5/8)   
Receiving objects:  75% (6/8)   
Receiving objects:  87% (7/8)   
Receiving objects: 100% (8/8)   
Receiving objects: 100% (8/8), done.
Resolving deltas:   0% (0/1)   
Resolving deltas: 100% (1/1)   
Resolving deltas: 100% (1/1), done.
Checking connectivity... done

有办法解决吗?

最佳答案

如果您不关心进度,您可以重定向输出:

git clone -q

--quiet
-q

Operate quietly. Progress is not reported to the standard error stream.
This flag is also passed to the `rsync' command when given.


3 年后更新:克隆存储库及其子模块时,此选项效果不佳。
Git 2.14.x/2.15(2017 年第 3 季度)已修复此问题

参见commit 03c004c (2017 年 8 月 3 日)作者:Brandon Williams (mbrandonw) .
(由 Junio C Hamano -- gitster --commit cd2a952 merge ,2017 年 8 月 22 日)

"git clone --recurse-submodules --quiet" did not pass the quiet option down to submodules.

关于Git:将 'git clone' 输出打印到文件中并删除进度子状态行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23865894/

相关文章:

git - 无法从 git 获取对 git post-update Hook 的依赖

git - TeamCity 分支规范 - 有没有办法排除所有子文件夹?

ruby-on-rails - git clone heroku ssh 权限被拒绝

git - 只为一个分支设置远程?

C# 如何使用 libgit2Sharp 读取提交时间

windows - .gitconfig 安装在 Windows 10 的错误驱动器上

git - 更好的 git add -p?

Github 提交语法以链接 pull 请求/问题

linux - Windows Git 服务器和 Linux Git 客户端

Git "Live Server"最佳实践