1

I made a "git add dir" and then committed and pushed. Then I realized it was best to not add the directory to the repository, so I deleted it with "git rm -r". However, I want to delete it from the history, so that it cannot be recovered from the git repository.

I have looked at BFG Repo Cleaner, but

  1. for some reason the directory has been added as a submodule to git: it has a .git subdirectory and in the logs it shows "Subproject commit 72ab72...". Can BFG Repo Cleaner remove this submodule?
  2. BFG does not seem to support removing a given directory. --delete-folders takes a glob as a parameter, and since the directory has a common name it may remove other directories too.

What should I do?

Thank you.

Gibezynu Nu
  • 354
  • 6
  • 15
  • Possible Duplicate: https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history – myselfmiqdad Mar 08 '18 at 18:11
  • Possible duplicate of [Remove folder and its contents from git/GitHub's history](https://stackoverflow.com/questions/10067848/remove-folder-and-its-contents-from-git-githubs-history) – myselfmiqdad Mar 08 '18 at 18:11
  • @miqdadamirali I used the guide "filter-branch" of https://help.github.com/articles/removing-sensitive-data-from-a-repository/ It is similar to the answer https://stackoverflow.com/a/32886427/7092558 Should I flag my question as duplicate or write an answer pointing to help.github.com? – Gibezynu Nu Mar 09 '18 at 12:31

1 Answers1

0

If it's the last commit that you'd like the remove you can

git reset HEAD

If you find that you need to go further, you'll need to either rebase or cherry pick. This is asked very often on stackoverflow but if there's a reason those answers don't help feel free to modify your question!

Seth Rothschild
  • 384
  • 1
  • 14