Git: unable to redirect / parse git fetch --dry-run 'command output

What is special about the output from the git fetch command that prints to the console? I can not use grep , xargs , etc. Unable to redirect output to file.

Note. I use the 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 am trying to parse the output of the git fetch --dry-run command to check if the local branch ( master ) is current with the remote branch ( origin/master ).

+4
source share
1 answer

Some of the git status output is sent to STDERR . If you want grep through it, merge STDERR into STDOUT like this:

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

Source: https://habr.com/ru/post/1443075/


All Articles