Search code examples
gitgithubrepositorypushgit-push

How to Remove Git repository and push new one


how can I Clear repository and push new one instead of it .

I have project with size more than 2GB , I checked .git folder and it's size is 1.5GB , I try to delete .git folder after that I did git init and force push project , but remote repository size not changed , my steps :

git init
git add . 
git commit -m "First Push"
git remote add origin http://Url_here
git push -f origin master

how to replace repository content ?


Solution

  • Few options:

    • Go to the server repository, delete the old repo and create a new one.
      In the current repo push the new branches

    • Create a new orphan branch and then push it.
      Now on your server run git gc --aggressive --prune=now to clean all the old commits

    • Use filter branch to clean all the old content

    • Use rebase -i and squash all your commits into one then push it

    • Use git subtree' split to create a new project from the existing code.Similar togit filter-tree` which in your with the right code will produce the same results.