使用xargs在git别名中显示命令

耶罗恩·德道

我的.gitconfig中有以下“全部推送”别名:

[alias]
    pall = !git remote | xargs -L1 -I R git push R

这使我可以通过

git pall master

使用3个遥控器,这给我的输出看起来像

Everything up-to-date
Everything up-to-date
Everything up-to-date

我正在寻找一种使命令显示实际执行内容的方法。就像是

git push remote1 master
    Everything up-to-date
git push remote2 master
    Everything up-to-date
git push remote3 master
    Everything up-to-date

我不确定如何访问branch参数。不像$ 1那样简单。如何修改别名,以便执行别名后会产生输出,说明上面显示了什么情况?

定制指挥官

我认为您可能需要xargs使用-t

在执行之前,将要执行的命令回显为标准错误。

$ seq 10 | xargs -t -I x echo "n=x"
echo n=1
n=1
echo n=2
n=2
echo n=3
n=3
echo n=4
n=4
echo n=5
n=5
echo n=6
n=6
echo n=7
n=7
echo n=8
n=8
echo n=9
n=9
echo n=10
n=10

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章