Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Since Git is cumulative, how to deal with that for long term when the repo becomes 5GB?

Tags:

git

For Git, since all the history is there, I am wondering, saying if I keep a repo for keeping all code I have written, over the 5 years or 10 years, with all revision history, then the repo becomes 5GB.

And if a machine doesn't have a repo, and I want to just try a code snippet or a small Rails project, I have to clone the whole 5GB over, and that won't be too practical.

Say, if out of the 5GB, only 200MB is the current files, and all the other are history, then at least if using SVN, then each machine will have the 200MB, instead of 5GB. Maybe Git is very suited for each self-contained small or medium projects, but what if it is a "long term my whole life repo", then how to use Git for it?

like image 397
nonopolarity Avatar asked Dec 17 '22 15:12

nonopolarity


2 Answers

Use multiple Git repositories. A single server can handle any number of repositories.

If you want to get dirty within a repository, you can create a new branch, rewrite it's history (merging multiple commits into one), and delete the first branch.

like image 53
yfeldblum Avatar answered Dec 19 '22 07:12

yfeldblum


You are correct sir, and the Git Wiki agrees with you. That being said, if you don't care about pushing/pulling changes from this hypothetical git repository, you can do a "shallow" clone to pull a commit without it's history:

git clone --depth X

Where X is how far back into the history you want to go. 1 will get you the most recent commit, 2 will pull the most recent and the one before, and so on and so fourth.

like image 44
Damien Wilson Avatar answered Dec 19 '22 06:12

Damien Wilson