1

My company website has a Git repo that includes some directories that contain a bunch of large binaries (PDFs, MP3s, etc.). Naturally, this has resulted in a really big repo which makes cloning it pretty impractical. There have been a large number of commits over a number of branches.

I've identified BFG Repo-Cleaner (which appears to simplify this process) as the means by which I want to remove these binaries from my repo. However, I don't understand the correct procedure to remove these files from the HEAD of my repository before running BFG (which works on the assumption that you latest commit has removed all the files to be cleaned from the history).

To clarify, my git index and working tree both currently live in the Document Root of the website. The files that I want to remove from the repository need to stay where they are in the Document Root. How can I tell Git to forget about these directories without them being deleted when I pull down subsequent changes?

Any help is much appreciated. Thanks!

ediv
  • 71
  • 1
  • 4

1 Answers1

0

If you have a ton of MP3 files in an audio directory, you could do this:

  1. Put a copy of the MP3 files somewhere else.
  2. git rm audio/*.mp3 to stage them for removal
  3. echo "*.mp3" >> .gitignore to have git ignore MP3 files in the future
  4. git add .gitignore to stage the ignore file
  5. git commit to commit the changes

Now the MP3 files will no longer be on HEAD, but if you put them back in the audio directory, git will ignore them.

Disclaimer: I didn't test this exact sequence, you might need to commit the deletion first, then update .gitignore in a separate commit, but I don't think so.

benzado
  • 82,288
  • 22
  • 110
  • 138