3

I have a working directory that I track with GIT on one of my computers and at some point in the past I created a remote (bare) repo on an external hard drive. This remote is called origin. I then cloned that repo on other computers at a later time. Since I created origin, I make sure I always keep it up to date by pushing all my changes from any computers to it. I then pull those changes back to the other computers so that my working directories are all the same.

The other day I decided to reorganize my external HDD. I created a new bare repo (let's call it other_remote) in a different location on the drive, added it as a new remote to my working directory on one of my computers and pushed that working directory to it.

Now, I was going to erase the repo origin from my HDD, but before proceeding, I had doubts and I decided to compare the two remote repos to make sure I was not doing something that I would regret.

I started with du and I got this:

$ du -sch origin                                                                                                                                  
207M    origin
207M    total

$ du -sch other_remote                                                                                                                      
34M     other_remote
34M     total

Now that scared me! I obviously didn't erase origin yet. I did a lot of research (here and on google) but I couldn't find any info about that.

The only thing I found was someone saying that you can use git count-objects -v to get a good estimate of the size of a repo. But again, this command gives quite different results on my two bare repos:

$ cd path/to/origin
$ git count-objects -v
count: 137
size: 211976
in-pack: 0
packs: 0
size-pack: 0
prune-packable: 0
garbage: 0

$ cd other/path/to/other_remote
$ git count-objects -v
count: 6
size: 9888
in-pack: 131
packs: 1
size-pack: 24725
prune-packable: 0
garbage: 0

Can anyone help me understand why my two remote repos are so different? Is it safe for me to erase origin and only keep other_remote? Will I loose some information if I do so?

Thanks a lot

couash
  • 31
  • 1

1 Answers1

0

First, git count-objects only count unpacked object (and in a bare repo, they are likely to be packed after the initial push).
See also "Why is my git repository so big?" for the causes of a larger repo for the same number of files, and "Do I ever need to run git gc on a bare repo?" (loose objects because of dangling commits)

The point is, a new bare repo is likely to be smaller than an active non-bare repo with the same history.

Then, make sure you have pushed everything (all branches, and all tags).
See for instance "With GitHub how do I push all branches when adding an existing repo?".
Did you just git push myNewBareRepo, or git push --all myNewBareRepo?

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283