作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个自动脚本可以解析服务器并克隆其中一个文件夹中的所有存储库。它所做的伪代码是:
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 上打印一条消息(我认为)说
You appear to have cloned an empty repository
好吧,谢谢你,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/
我是一名优秀的程序员,十分优秀!