2

I added a really big file to a repository and committed it, then deleted the folder and did git add -u . The problem I have is that now when i try to push to a remote repository it takes way too long to upload those already deleted files I had commited.

Is there any way to remove all traces of the folder so the repo acts like that folder has never existed and doesn't try to upload the now non-existent folder?

I tried git clean -f -d

2 Answers 2

4

You need to filter the history of the repository (and hence change all the commit ids after this commit) in order to do so.

One way to do this is to use git filter-branch to filter out the file you don't want. There's a nice step-by-step for this (including some .gitignore stuff you may not need for your use) on GitHub's Remove Sensitive Data page.

The other way is to simply do a git rebase -i against a commit before the one that added the bad file, and omit both that and the commit you made deleting the file.

In both cases, you make the modifications locally and the (force) push the new version up to your central repo and make it available to your collaborators.

Sign up to request clarification or add additional context in comments.

Comments

1

Have a look at the BFG Repo-Cleaner. It’s a tool written for exactly that purpose.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.