我有一个自动脚本,可以解析服务器并克隆其中一个文件夹中的所有存储库。它所做的伪代码是:
for each repo_name
if a folder named like repo_name exists in .
cd repo_name
git fetch origin
else
git clone repo_url
end
end
这些存储库有时是空存储库。然后 git clone 命令失败 - 或者我使用的脚本认为它失败了。它在 stderror 上打印一条消息(我认为)说
好吧,谢谢你,git,但这并没有错。
我尝试将
--quiet
选项添加到命令中,但该消息不断出现。有没有办法抑制它,而不抑制其余可能的错误?
最佳答案
不是很优雅,但是如何将 stderr
重定向到 stdout
并使用 grep
过滤该错误?
git clone repo_url 2>&1 | grep -v 'warning: You appear to have cloned an empty repository.'
关于git clone - 如何抑制 "You appear to have cloned an empty repository"警告?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8941594/