控制台上打印的git fetch命令输出消息有什么特别之处?我无法使用grep、xargs等。也无法将输出重定向到文件。
注意:我使用的是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)分支保持最新。
发布于 2012-10-31 03:29:11
git的一些状态输出会发送到STDERR。如果您希望grep通过它,将STDERR合并到STDOUT中,如下所示:
git fetch --dry-run 2>&1 | grep sshhttps://stackoverflow.com/questions/13146187
复制相似问题