How do I check whether the remote repository has changed and I need to pull?
Now I use this simple script:
git pull --dry-run | grep -q -v \'Already
I would do the way suggested by brool. The following one-line script takes the SHA1 of your last commited version and compares it to the one of the remote origin, and pull changes only if they differ.
And it's even more light-weight of the solutions based on git pull
or git fetch
.
[ `git log --pretty=%H ...refs/heads/master^` != `git ls-remote origin
-h refs/heads/master |cut -f1` ] && git pull