5

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

4

1 に答える 1

10

gitのステータス出力の一部はになりSTDERRます。grepを実行する場合は、次のようにSTDERRをSTDOUTにマージします。

git fetch --dry-run 2>&1 | grep ssh
于 2012-10-30T19:29:10.607 に答える