Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does git push from local to remote compress data?

My local repository has about 500 files and a total size of about 125MB. I initialized a git repository on storage provided by "http://repositoryhosting.com/".

I did the following steps via Git GUI

  • git commit (of my local repo)
  • git remote add
  • git push

It said that it uploaded onto the Remote Repo and I could see the files, but the repo now had a size of only 26 MB.

I tried to git clone and git pull on two different occasions on another machine from the remote repo. They seemed to download exactly the 26MB that was on the Remote repo. But when I check the size of the folder on the machine, it shows that it is 125MB.

Questions:

  1. Does 'git push' compress data while uploading to Remote Repo?
  2. Am I losing data?
  3. If I'm trying to make a copy of the Remote Repo on multiple local machines so that multiple people can work on the same project, do I use Git Clone or Git Pull?
like image 770
nitred Avatar asked Feb 11 '14 07:02

nitred


People also ask

Does git compress data?

Git has a mechanism to compress all files (and indeed, all history) into pack files.

Does git push push to all remotes?

Running git pushall will now push all branches to all remotes.

Does git LFS use compression?

Git LFS does not compress files. Some files are compressible, and some are not. It, like Git's partial clone feature, is designed to offload most of the data to a trusted server for the purposes of making local access lighter and cheaper.

What kind of compression does git use?

Git Compression of Blobs and Packfiles. Many users of Git are curious about the lack of delta compression at the object (blob) level when commits are first written. This efficiency is saved until the pack file is written. Loose objects are written in compressed, but non-delta format at the time of each commit.


2 Answers

Does 'git push' compress data while uploading to Remote Repo?

Yes. It pushes diff delta pack files.

Am I losing data?

No.
Once you start working on a repo, you:

  • checkout those packed files in a working tree
  • work with added files stored in .git/objects, which aren't re-packed yet.
    see "Git Internals - Packfiles" for more.

If I'm trying to make a copy of the Remote Repo on multiple local machines so that multiple people can work on the same project, do I use Git Clone or Git Pull?

git clone for the initial copy and checkout of that repo.
Then git pull.

like image 168
VonC Avatar answered Oct 10 '22 00:10

VonC


Apart from what's already been said, Git's content-addressable storage model naturally deduplicates data, i.e. files with identical contents are stored only once. I highly doubt that this comes to play in your case, but generally and depending on what type of data you store this is another reason why Git's storage is fairly efficient.

like image 25
Magnus Bäck Avatar answered Oct 10 '22 00:10

Magnus Bäck