Blogged by Ujihisa. Standard methods of programming and thoughts including Clojure, Vim, LLVM, Haskell, Ruby and Mathematics written by a Japanese programmer. github/ujihisa

Monday, September 14, 2009

Git Lessons Learned For Speedup

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

Followers