Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to clean git log in .git when it's becoming to big

Tags:

git

I really dislike to have monster .git folder (2GB) and I don't care about changes in 2002 and I don't want to create new repository so what should I do to clean .git / log ?

Note that I want it not local-only, next time I want to clone repository without history or with history since 2011 year.

thank you

like image 214
cnd Avatar asked Jan 23 '12 09:01

cnd


1 Answers

From your question, I think you want something like this.

git-rebase(1) does exactly that.

$ git rebase -i HEAD~5

git awsome-ness contains an example.

  1. Don't use git-rebase on public (remote) commits.
  2. Make sure your working directory is clean (commit or stash your current changes).
  3. Run the above command. It launches your $EDITOR.
  4. Replace pick before C and D by squash. It will meld C and D into B. If you want to delete a commit then just delete its line.

If you are lost, type:

$ git rebase --abort  

However, to copmress the .git folder safely, the above is not recommended. You can try the following as mentioned in a comment by Linus.

git repack -a -d --depth=250 --window=250

where that depth thing is just about how deep the delta chains can be (make them longer for old history - it's worth the space overhead), and the window thing is about how big an object window we want each delta candidate to scan.

like image 77
Pulkit Goyal Avatar answered Nov 10 '22 01:11

Pulkit Goyal