I'm writing a shell script to automatically update several directories of git repos, and I want to ignore repos that do not have a remote origin to pull from. So far I have
if git remote 2>&1 >/dev/null; then
which successfully determines whether a directory is a git repo. But for any new git repo,
git remote
returns "origin" and an error status of 0. How do I distinguish between such repos and a repo where the command git pull
will do something?
I could use
git remote show origin
but this will connect to the origin server if it exists, and I'd prefer a command that's fast and local.