3

I take care of the Git repositories of the company. We use Gitosis to manage the Git repositories. I clone one repository via git clone git@gitserver:repo, and some commits are not found at all. git show <commit> returns fatal: bad object f723e2ea9af0e380158d90c36e21a60991760d31.

The objects are below, there are only one pack file:

$ tree .git/objects/
.git/objects/
|-- info
|   `-- packs
`-- pack
    |-- pack-4d930eca23ad902fc4a4809d01b86c4217b0b262.idx
    `-- pack-4d930eca23ad902fc4a4809d01b86c4217b0b262.pack

2 directories, 3 files

I cannot find the commit in the pack file:

$ git verify-pack -v .git/objects/pack/pack-4d930eca23ad902fc4a4809d01b86c4217b0b262.idx | grep f723e2e
$

When I clone the repository on the Git server using local file system, the commits are there and can be checked out.

I can find the commit (the first one):

$ ls .git/objects/f7/
23e2ea9af0e380158d90c36e21a60991760d31  84f33d44863cbe6ca4ae03cddcc673048f04bb
3b1ef7031d634b4aa443925dd29cc779356caa  9807359a1c65f312a1d4642e5191416443e20b
6fbd26fccc5a8e89f221c9196eb8083e73632e

How can my users get all the commits when cloning via SSH?

Fish Monitor
  • 4,155
  • 3
  • 32
  • 53
  • 1
    Check the consistency of the remote repo, it seems to be broken somehow (the error message says pieces are missing). – vonbrand Feb 18 '13 at 06:25

1 Answers1

1

Since you can clone on the server, try a git bundle, which will give you one file.

Then copy that file on your local machine, and clone from that bundle.

You can check, after that "bundle" clone, if you can:

  • add a remote back to the gitosis repo
  • push/pull from said upstream gitosis repo.

(Note: when you find commits on a corrupt repo, check if their size is 0, and try delete it, or restore it from another clone)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I create the bundle using `git bundle create poi --branches --tags`. Then clone from the bundle file, the content of `.git/objects` is the same with the repository cloned via SSH, i.e. the two pack files in my OP, which still misses some commits. – Fish Monitor Feb 18 '13 at 08:19
  • @fossilet note that you could copy over the bundle, and clone locally (to eliminate any influence of SSH). Regarding the missing objects, any chance you can find them on a clone on the server side? – VonC Feb 18 '13 at 08:24
  • Yes I clone from the bundle, but the last message is `warning: remote HEAD refers to nonexistent ref, unable to checkout. `. When cloning from local file system, the commits can be displayed by `git show`, but they are missing in `git log`, though FishEye can display the commits. – Fish Monitor Feb 18 '13 at 08:35
  • 1
    @fossilet Darn. And I suppose `git fsck` doesn't add any new information? – VonC Feb 18 '13 at 08:50
  • For the local clone, it gives two dangling commits. For the SSH clone and bundle, no error is given. – Fish Monitor Feb 18 '13 at 09:25
  • @fossilet strange, that means you should be able to restore said dangling commits by finding the right object on the server, and copying them over to the clone on the client. – VonC Feb 18 '13 at 09:39