I did not use .gitignore to ignore files such as compiled binaries in my project, so these compiled binaries have been committed into the Git repository. And now I add .gitignore to my project. I want to rebuild the whole Git repo ignoring the files listed in .gitignore without losing any history. How can I do that?
Asked
Active
Viewed 299 times
1 Answers
2
Remove those binary from the current cache if they were just added.
git rm --cached abinary
Then your .gitignore
will automatically ignores those binaries.
But if they were committed in past commits, You won't loose history, but you still need to remove those binaries from said commit.
You will need either git filter-branch
or bfg repo cleaner.
That will rewrite your history, and you will need a git push --force
, so if you have more than one (yourself) collaborator, warn them in advance.

VonC
- 1,262,500
- 529
- 4,410
- 5,250