Let's say i have a code like this:
git fetch && git diff origin origin/master --quiet || echo "untracked"
And i want it to run periodically. Let's say, once a second, or once per five seconds and so on.
If this code outputs "untracked", or in other words, if there is an update on the remote,i will run a git pull
to update the local code.
Question is: Is it bad to do something like this? I mean, i know that it would be a constant request on the remote server. But, is it bad? And apart from that, is there any other side effects? Thank you very much.
Beside making other commands fail if executed too often, then main drawback of a regular fetch is on the push --force-with-lease
.
I have documented as much in "push --force-with-lease
by default"
--force-with-lease
or--force-with-lease=<refname>
interacts very badly with anything that implicitly runsgit fetch
on the remote to be pushed to in the background, e.g.git fetch origin
on your repository in a cronjob.The protection it offers over
--force
is ensuring that subsequent changes your work wasn't based on aren't clobbered, but this is trivially defeated if some background process is updating refs in the background.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With