github - Completely remove every trace of git commit -


following situation: have git repo lot of commits, , want remove file introduced in commit changed in few , deleted in commit. want remove commit repo , therefore did:

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch unwanted_file' --prune-empty --tag-name-filter cat -- --all git push -f origin master

this worked great , history rewritten (several commits rewritten. however:

git log --all -- unwanted_file

i still 2 entries showing up, namely commits nothing else removing file , adding file done.

alll other commits other things done gone. how can remove last traces of these commits well?

the canonical guide removing commit here. in essence gives 2 routes, git-filter-branch, , bfg.

however, if mean completely remove, missing step 9 in process, i.e. :

git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin git reflog expire --expire=now --all git gc --prune=now 

which delete unused references.

note if these either sensitive data should never have been committed, or huge (so don't want git pull pull them down again), need ensure removed from:

  • the upstream repo (and other upstream repos)
  • all collaborator's repos (so don't push them back) - it's easier ask them delete repo , reclone.

note comment in there getting collaborators rebase rather merge.


Comments