gpt4 book ai didi

Git:无法重定向/解析 'git fetch --dry-run' 命令的输出

转载 作者:太空狗 更新时间:2023-10-29 13:30:57 25 4
gpt4 key购买 nike

控制台打印的 git fetch 命令的输出信息有什么特别之处?我无法使用 grepxargs 等。也无法将输出重定向到文件..

注意:我正在使用 git fetch --dry-run 命令

[sangeeth@localhost santest-code]$ 
[sangeeth@localhost santest-code]$ git fetch --dry-run > /tmp/1
From ssh://git.code.sf.net/p/santest/code
9f068d0..2b9dc4e master -> origin/master
[sangeeth@localhost santest-code]$
[sangeeth@localhost santest-code]$ cat /tmp/1 <= no data
[sangeeth@localhost santest-code]$
[sangeeth@localhost santest-code]$ git fetch --dry-run | grep "ssh" <= output has both lines
From ssh://git.code.sf.net/p/santest/code
9f068d0..2b9dc4e master -> origin/master
[sangeeth@localhost santest-code]$
[sangeeth@localhost santest-code]$ git --version
git version 1.7.11.4
[sangeeth@localhost santest-code]$

我正在尝试解析 git fetch --dry-run 命令的输出以检查本地 (master) 分支是否是最新的远程 (origin/master) 分支。

最佳答案

一些 git 的状态输出到 STDERR。如果你想 grep 通过它,像这样将 STDERR merge 到 STDOUT 中:

git fetch --dry-run 2>&1 | grep ssh

关于Git:无法重定向/解析 'git fetch --dry-run' 命令的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13146187/

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