git fetch goes over the network and fetches the latest snapshot from origin/master to the local host. It does not merge but just fetches the snapshot. Right after git fetch if we do git status, it will tell us whether (local) master is ahead or behind origin/master.
All I want is a git command that will just tell us whether the content of (local) master is the equivalent of the content of origin/master. Obviously, it has to go over the network to determine that but it should not print any messages about its findings (like the output of git fetch or any other git command) and finally, just output only yes/true (if equivalent) or no/false (if different) or something similar.
Is there any git internal commands or api’s which could do this?!
I finally used the following snippet of code.
Had a problem parsing the output of
git fetch --dry-runbut found that the console messages belong tostderrGit: unable to redirect/parse the output of 'git fetch –dry-run' command