0

I'm working with a legacy project that included in the repository a directory that should have been ignored. The contents of this directory is causing a huge number of irrelevant conflicts while rebasing.

Is there a way to completely remove this directory from the history (as if it had been gitignored from the beginning)?

cfischer
  • 24,452
  • 37
  • 131
  • 214
  • Only if you've never pushed the changes, and no one's ever pulled them from you. Even in that case, though, you'd have to muck around with every commit that touched the affected files. – cHao Aug 15 '13 at 20:03
  • 2
    You want `git filter-branch`. Beware that this will break pulls. (Like rebase) – SLaks Aug 15 '13 at 20:03
  • Duplicate of [Removing code from GitHub](http://stackoverflow.com/q/443896/578288) (in terms of the answers, not necessarily the question). See [GitHub Help: Remove sensitive data](https://help.github.com/articles/remove-sensitive-data), which the top answer links to. – Rory O'Kane Aug 15 '13 at 21:03
  • @SLaks Please add this as an answer, and I'll accept it right away. – cfischer Aug 15 '13 at 21:41

1 Answers1

1

You want git filter-branch, which will rewrite every commit in your branch.

Beware that this will break pulls (just like rebase).

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964