Git:无法重定向/解析'git fetch --dry-run'命令的输出 [英] Git: unable to redirect/parse the output of 'git fetch --dry-run' command
问题描述
控制台上打印的 git fetch
命令的输出消息的特别之处是什么?我无法使用 grep
, xargs
等等,也无法将输出重定向到文件。 。
$ b
注意:我使用 git fetch --dry-run
命令
[sangeeth @ localhost santest-code] $
[sangeeth @ localhost santest-code] $ git fetch --dry-run> / tmp / 1
从ssh://git.code.sf.net/p/santest/code
9f068d0..2b9dc4e master - >源/主
[sangeeth @ localhost santest-code] $
[sangeeth @ localhost santest-code] $ cat / tmp / 1< =无数据
[sangeeth @ localhost santest-code ] $
[sangeeth @ localhost santest-code] $ git fetch --dry-run | grepssh< = output同时包含两行
从ssh://git.code.sf.net/p/santest/code
9f068d0..2b9dc4e master - >源/主
[sangeeth @ localhost santest-code] $
[sangeeth @ localhost santest-code] $ git --version
git版本1.7.11.4
[sangeeth @ localhost santest-code]
我试图解析 git的输出抓取--dry-run
命令来检查本地( master
)分支是否与远程(<$ c $)是最新的c> origin / master )分支。
git的一些状态输出到 STDERR
。如果你想通过它,将STDERR合并到STDOUT中,如下所示:
git fetch --dry-run 2>& 1 | grep ssh
What is special about the output message of git fetch
command that is printed on the console? I'm not able to use grep
, xargs
, etc. Not able to redirect the output to a file also..
Note: I'm using git fetch --dry-run
command
[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]$
I'm trying to parse the output of git fetch --dry-run
command to check whether the local (master
) branch is up-to-date with the remote (origin/master
) branch.
Some of git's status output goes to STDERR
. If you want to grep through it, merge STDERR into STDOUT like so:
git fetch --dry-run 2>&1 | grep ssh
这篇关于Git:无法重定向/解析'git fetch --dry-run'命令的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!