Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing git repo's remote, missing some data?

Tags:

git

I have a git repo online with BitBucket. It's approx. 31 MB in size. I decided to move it to a new location. So I created a new remote repo, an empty one.

I then cloned the old repo onto my computer, changed the remote URL (in .git/config) to the new location of the empty repo I just created, then I checked out all the branches with this line of code:

for remote in `git branch -r | grep -v master `; do git checkout --track $remote ; done

After that finished, I ran:

git push --all

After all that uploaded, I checked the new repo and as expected, all the source seems to be there, and all the branches too.

But the new repo is only 8.5 MB in size.

All my content seems to be there, but something must have got forgotten to give me over 20MB of freed space.

What may have gone missing in the process?


Details

Cloning my "slim" repo, here are some stats, running git count-objects -v:

count: 0
size: 0
in-pack: 4727
packs: 1
size-pack: 7998
prune-packable: 0
garbage: 0

A fresh clone of the original repo gave me this:

count: 0
size: 0
in-pack: 4727
packs: 1
size-pack: 7945
prune-packable: 0
garbage: 0

size-pack is actually smaller from the original 31MB repo

Just to clarify, when I say the size is different, on disk I have 18.8MB vs 18.7MB, but online at BitBucket the overview page is reporting 31MB vs 8.5MB. Does that change something?

like image 830
Daniel Avatar asked Jun 11 '26 17:06

Daniel


1 Answers

Try running git gc on your local repository, it might get smaller without losing anything. (except garbage :D)

like image 168
Niko Sams Avatar answered Jun 14 '26 08:06

Niko Sams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!