Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 5

[git][windows] Preventing local file bloat

Solved! Go to Solution.

I'm using GitHub Desktop and git.exe for my repo and am running into an issue.

 

Over time the local repos folder bloats out to over 500MB for a remote repo that is under 11MB.

 

I have a PowerShell script that runs the following commands:

 

clean -f
checkout --orphan TEMP_BRANCH
add -A
commit -am "Initial Commit"
branch -D master
branch -m master
push -f origin master

I'm trying to get it to:

  1. retain the latest commit only
  2. delete all old history and old files
  3. clean the .git folder

for both remote and local.

 

Any ideas?

4 Replies
Commander Lvl 2
Message 2 of 5

Re: [git][windows] Preventing local file bloat

checkout --orphan TEMP_BRANCH HEAD~1

to get only the last commit?

 

No, that's not right I think.

 

I know that "git clone" has a --depth option to get a limited history. 

 

Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!

Community Manager
Message 3 of 5

Re: [git][windows] Preventing local file bloat

It sounds like you're using git for something that it wasn't designed for. I suspect that you have a lot of binary files in the repository, files such as audio, image, or video files. And then on top of that, you're intentionally not using any of the version control features of git, using it only as a remote file storage mechanism.

 

Unfortunately, it's not possible to tell git to work in such a way. It's going to assume that you're trying to use it as a version control system and keep extra data around in case you decide to refer back to it. You could look into the `git gc` command to see if it could help, but I would still recommend using a different tool that is better designed for what you're trying to do.

 

I hope that helps!

Commander Lvl 2
Message 4 of 5

Re: [git][windows] Preventing local file bloat

Potentially useful article about using git-sizer to determine how your repository is "too big".

 

Also, is 500M "size" or "allocated size"? I have a 5M repo which occupies 75M of disk space on one device - each of many 1K files occupies 128K of allocated disk space.

 

Please follow-up to let us know how you made out. For good karma, mark a reply as the answer if it helped!

Solution
Copilot Lvl 2
Message 5 of 5

Re: [git][windows] Preventing local file bloat

Thanks everyone for the replies :D

 

To prevent bloat I've decided to just delete the local repo folder and clone down the repo after every 20 commits.