1

what I've done:

git clone ssh://... ...
git commit
...
git commit

but there was a file (something secret ;) which I should never push. Normally, i would have done something like

git reset --soft HEAD^

to undo the last one, but it was too many commits ago

or:

git diff REV > /file.patch

to apply it on the top of remote/master, but I want to keep current commits

Stedy
  • 7,359
  • 14
  • 57
  • 77
Vlad Bokov
  • 361
  • 2
  • 9
  • 2
    this might help: http://stackoverflow.com/questions/872565/how-do-i-remove-sensitive-files-from-gits-history – zoran119 Dec 14 '11 at 08:42
  • 3
    And this too: http://help.github.com/remove-sensitive-data/ – Ikke Dec 14 '11 at 09:00
  • if you have pushed, there is no way to to keep you current commits as is, and try to fix as in the previous two comments, unfortunately. – Thong Kuah Dec 14 '11 at 09:14

1 Answers1

1

This works for me

git filter-branch --tree-filter 'rm -f passwords.txt' HEAD

ref

Zombo
  • 1
  • 62
  • 391
  • 407
  • Note that, as with all suggestions on this Q&A, the commit IDs will be changed from the first commit to be changed; so if you're sharing history with others, you'll need to co-ordinate with others to take your new history. – Asherah Jun 26 '12 at 23:24