Tibor's Musings

Git Fetch Trouble Workaround

When fetching from a git repository such as Invenio one, you may encounter a situation where fetching a branch does not work due to missing objects, all the while cloning the same repository anew works well. Here is how to work around the fetching problem.

If fetching replies:

$ cd ~/private/src/invenio
$ git fetch sam -p
error: Unable to find 990baa93fc7bfd2beda20a70daf28bb5eda43976 under http://invenio-software.org/repo/personal/invenio-sam
Cannot obtain needed tree 990baa93fc7bfd2beda20a70daf28bb5eda43976
while processing commit 01a973828cef3385f23f4a58d9f630c946426d83.
error: Fetch failed.

Then the workaround solution is to temporarily make a full clone of the repository and fetch the missing tree from there:

$ cd /tmp
$ git clone --bare http://invenio-software.org/repo/personal/invenio-sam
$ cd -
$ git remote add samtmp /tmp/invenio-sam
$ git fetch samtmp
$ git remote rm samtmp

Now regular fetching should work again:

$ git fetch sam # now works

git