2

I have a git repository with 2-3 GB size of files and the same files I have on my local machine as backup. How do I clone the git repository on my local so that it replaced my unversioned files with git repo files to save time and bandwidth.

Umar Adil
  • 5,128
  • 6
  • 29
  • 47

1 Answers1

0

I have not tested this, but in theory, I think it should work:

First, init a new git repository in the folder where you have the local files with git init and add the correct remote with git remote add ...

Then, create the blobs from your local files with git hash-object:

git hash-object -w file1
git hash-object -w file2
git hash-object -w file3

At this point, move the local files away from the git managed directory so that they do not interfere.

After that, do git pull - it should not download the blobs that you already have. Note that if these files have changed at some point in the repositorys history, it will download the older versions.

1615903
  • 32,635
  • 12
  • 70
  • 99