Leahcim
Leahcim

Reputation: 42069

where does git store its objects before the target directory is made

I cloned a git repo using the following command but interrupted the clone before all the objects were received. When I interrupted the clone, the new directory ('some-project') hadn't been created yet, however, git tells me that I had received 100+mb of data. If I let the clone runto completion, then the data would be in 'some-project' but since 'some-project' dir was never created, where is the data?

git clone https://git.somehost.org/some-project.git

Cloning into 'some-project'...
remote: Counting objects: 5646714, done.
remote: Compressing objects: 100% (593005/593005), done.
^Cceiving objects:   9% (510470/5646714), 106.60 MiB | 739.00 KiB/s 

Upvotes: 0

Views: 34

Answers (2)

AnoE
AnoE

Reputation: 8355

Git stores everything in the form of "objects". Those live under .git/objects inside your local repository. In normal use, those objects are file contents ("blobs"), directory listings ("trees"), commits, signed tags and assorted minor things.

All your downloaded stuff is in there as well.

In fact, you can just watch it as it downloads. Grab any very large repository (e.g., Rails or whatever) and while it downloads, list all files in your new repository, ls -lR rails).

You will find files like this:

.git/objects/pack/tmp_pack_9UcqDb

A "pack" is just a bunch of git objects packed inside a larger file, for compression/storage optimization.

As you press ^C, git thankfully removes the new directory it created.

Upvotes: 1

torek
torek

Reputation: 490168

Git creates the clone target and puts the files into it as it goes. If you interrupt the clone process, Git removes the clone target, taking the files with it.

Upvotes: 2

Related Questions