0

Possible Duplicate:
Remove sensitive files and their commits from Git history

I noticed that due to a server move, for whatever reason.... I accidentally somehow committed a file that has been ignored by git for months. Needless to say i don't want it part of the repo.

Unfortunately I pushed this file to my remote repo in three different commits.

What would be the easiest way to remove that file from three local and remote commits without the most collateral damage?

Thanks for your help. My theory would be to pull that commit and maybe ammend it and force push it back. Anyone know how I can do this?

Community
  • 1
  • 1
d-_-b
  • 21,536
  • 40
  • 150
  • 256

2 Answers2

1

Github has a great guide for fixing issues like this: Remove sensitive data

Dan McClain
  • 11,780
  • 9
  • 47
  • 67
  • Thanks! If i understand it correctly it tells how to remove the file from the entire repo (which is perfect) but what about updating the remote repo? – d-_-b Oct 13 '12 at 01:36
  • thanks for the link to the duplicate question. that is exactly what i was looking for! – d-_-b Oct 13 '12 at 01:40
0

use

git filter-branch

to remove that via an index filter (the docs have examples of this). After that just force push all public branches that were affected. You will see that the remote tracking branches duplicate all the commits. The force push will fix that. Then send out a message about what you did to anyone working with you. They will be able to fetch and rebase their work with no issue as you didn't change anything that they should be referencing.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141