1

I have a .git folder thats 788MB in size. I noticed that the largest folder in the directory is the objects/pack folder.

To give a bit of context, I have a lot of projects which use git to extract information like Last Commit Hash, Author, etc. It turns out that when these projects go into my CI/CD pipeline, most of the time is spent uploading the .git directory.

I want to find a way to boil down a .git folder to only contain the necessary files to show me the last commit. Everything else is unimportant.

Does anyone have any thoughts on how I could approach this problem? Thanks in advance.

Update: the above question is asking how to boil down a .git folder before uploading to make the upload time a ton quicker.

Thomas Gouder
  • 125
  • 2
  • 2
  • 9
  • Does this answer your question? [Using git to get just the latest revision](https://stackoverflow.com/questions/1209999/using-git-to-get-just-the-latest-revision) – krisz Mar 30 '20 at 16:14
  • Unfortunately the above shows you how to do this whilst cloning - I'd like to do this with an existing .git repository. (no remotes) – Thomas Gouder Mar 30 '20 at 16:15
  • You can clone a local folder. – krisz Mar 30 '20 at 16:16
  • 2
    *only contain the necessary files to show me the last commit. Everything else is unimportant* sounds like you are using the wrong tool for your task. – j6t Mar 30 '20 at 16:19
  • --depth did do quite some good stuff.. But the pack folder is still massive (for some reason) – Thomas Gouder Mar 30 '20 at 16:46

1 Answers1

2
git clone --depth 1 --no-local --bare [--branch <branch or tag>] path/to/repo
krisz
  • 2,140
  • 2
  • 7
  • 12