Related question: why does Git send whole repository each time push origin master
The short version: When working with two Git repositories, even if 99% of the commit objects are identical, using git push
to send a commit to repository B when origin
is set to point to repo A causes all objects (200MB +) to be transferred.
The much longer version: We have a second Git repository set up on our continuous integration server. After we have prepared our commit objects locally, instead of pushing directly to origin/master
as one normally would, we instead push our changes to a branch on this second repository. The CI server picks up the new branch, auto-rebases it onto master
, runs our integration tests and, if all is well, pushes the branch to origin/master
on the master repo.
The CI server also periodically calls git fetch
to retrieve the latest copy of origin/master
from the master repo, in case someone has gone around the CI process and pushed directly.
This works wonderfully, especially if one does a git fetch; git rebase origin/master
before pushing to the CI repo; Git only sends the commit objects that are not already in origin/master
. If one skips the fetch/rebase step before pushing, the process still works, but Git appears to send, if not all, then a majority of commit objects to the CI repo -- currently more than 200MB worth. (A fresh clone of our repo clocks in at 225MB.)
Are we doing something wrong? Is there a way to correct this behaviour such that Git only sends the commit objects it needs to form the branch on the CI repo? We can obviously work around the issue by doing a pre-push git fetch; git rebase origin/master
, but it feels like we should be able to skip that step, especially because pushing directly to the master repo does not present the same problem.
Our repos are served up by Gitosis 0.2, and our clients are overwhelmingly running msysgit 1.7.3.1-preview.