I have some repositories that keep growing in size, so far this has not presented a problem for me, but I can not help but thing that at some point in the future it will sooner or later. So for now I thought I would take a moment tot just fool around with a test git folder, and do a little research on how to know how big a git repository is to begin with at least.
In late versions of git there is the git count-objects command that can be used to know how many objects there are and there disk consumption. So this might be the best way to know how much space a git folder is taking up assuming that I will always be using a late version of git that will support this.
I often find that it might be best to start over with a test repository rather than a clone of a repository that I might end up accidentally pushing changes to. So in this section I will be creating a whole new repository with git, and then use the git count-objects command to track the size of the repository.
First off I create a new repository with the git init command in a new folder.
I will then want to add something to it such as a dummy README file. Anything will do for this example at least just so that I add some content of some kind or another.
And a first commit.
So now I just need to call the git count-objects command in the git folder to get a count of all the objects, and a size value. If I call it without any arguments I get a size in kilobytes.
However there are some options that can result in a more detailed output of what is going on so far in this test repository. By passing the v option I get a more verbose output. On top of that there is also the uppercase H option that will give the output in a more Human readable form.
Anoher way to get an idea of how large a repo is there is the github API if it is a public repo. The linux curl command can be used to pull down the JSON data of a repo, and then redireciton can be used push status info to dev\/null. Then end reult of the JSON data can then be piped to grep to get just the size key of the JSON.
That will be it for now when it comes to the size of a git folder. There might be a great deal more to write about with this one when I get around to expanding on this subject a bit more when more things come up. There is just keeping in mind that I can not just cd into the root folder and do a linux du command to get an idea of the size. There is the question if the local repo is a deep clone or not, and there are just a lot of factors at play here when it comes to knowing what the actaul size is.