How to Free local hard disk space ?

Hi

Problem:
Whenever you “update” github repositories, the amount of used space on your local hard disk increases.
If, like me, you update many files, and / or very heavy files, the amount of space used by the hard disk really grows a lot.
I do not care to keep track of the whole history of the repository,
The last version is enough for me. (especially regarding the “Site” https://miorsoft.github.io/Site/index.html)
I need to free space on the local hard disk.
And I suppose you can do this by removing all the history of the repository.
Here, how is it done?

I could try this way, but first I would like to have some more certainty.

-Create a local copy of the Repo.
-Remove all the Github data from this copy (".git" folder)

  • Delete the old copy and rename the new one with the name of the Repo.
  • Go to the browser and permanently delete the Repo.
  • Upload to the Repo disk copy using the same name (of the deleted one)

Can someone give me useful and detailed information / links on how to proceed?

Thanks

You could just do it like this ( WARNING - this deletes your entire Git history, on ALL branches! ):

cd <repository root>
rm -R ./.git
git init
git remote add origin <repo location on GH>
git push origin master —force

It deletes the Git repo locally, then creates a new one, then adds your repo on GH as a remote and force pushes it to GH, overwriting any changes there.

2 Likes

Thanks it works but at Push I had this error:

error: src refspec master does not match any. error: failed to push some refs to 'ssh://xxxxx.com/project.git'

so, before push I did:

git add --all :/
git commit -am 'message'

So the complete  command sequence should be:

cd <repository root>
rm -R ./.git
git init
git remote add origin <repo location on GH>

git add --all :/
git commit -am 'message'

git push origin master —force

Correct me if I’m wrong (First time in git SHELL) so a lot insecure.

Thanks again

You’re right. I am sorry - i forgot that you had to commit first… What you have here is good.