0

The Web.config was commited in ~2nd commit out of ~20.

I'm sure its commit was an accident, however I would ideally want to unprivate repo - so Web.config needs to be gone from existence and history of the universe as well as git logs and github. :)

Is it possible and if yes, then how? Thanks for taking your time to read this.

  • Welcome to SO. You may want to have a look at [_how do I ask a good question_](https://stackoverflow.com/help/how-to-ask). Ideally you want to include in your questions what you have tried, where you have looked, etc. – ardila Feb 01 '19 at 18:39
  • https://stackoverflow.com/search?q=%5Bgit%5D+delete+file+history – phd Feb 01 '19 at 18:46
  • Sorry, my bad. I didn't look into enough of them to notice. But thanks for an answer regardless. :) – Liudvikas Taluntis Feb 01 '19 at 21:38

2 Answers2

0

Yes, this is such a common occurrence that it's been included in the documentation.

The command will be something along the lines of

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

It’s generally a good idea to do this in a testing branch and then hard-reset your master branch after you’ve determined the outcome is what you really want. To run filter-branch on all your branches, you can pass --all to the command.

ardila
  • 1,277
  • 1
  • 13
  • 24
0

You can re-write the history using rebase command. With some limitations:

  • If you already pushed it to remote repository you would need to force push it
  • If there are more changes to the file in other commits, you would have conflict on each one of them

You should do the following:

git rebase HEAD~20
  • Select the commit that added web.config and change pick to edit
  • Remove web.config file and run git rebase --continue

You should have no further conflicts, if this was the only commit that changed this file.

I suggest to also read: How to modify a specified commit?

Igal S.
  • 13,146
  • 5
  • 30
  • 48