TOPIC: To know whether we can push
or not without doing pull
.
git status
isn't reliable for this purpose. Even if the result was the following, it doesn't mean we can push
without pull
. The current branch may be outdated with origin's.
# On branch master
nothing to commit (working directory clean)
git ls-remote origin master
is also not. Once we committed, the sha1 is already changed, therefore we cannot compare it to remote's.
So, although this has side effects, git fetch
is the best solution for this problem.
Doing git fetch
periodically on background, and then checking git status
is fast and easy way.
In short,
$ ruby -e 'loop { `git fetch` }'
In another shell.
No comments:
Post a Comment