gitcheckin

How to remove a file including its history (removing history is important) from master branch where I don't have force push permission?


Tried below but didn't work.

  1. Created my local branch from master.
  2. Ran this command in my local branch and pushed it to remote. I was able to remove file (including its history) from my branch.
    $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch Folder1/Folder2/File1.csv' HEAD
    $ git push --force
  3. Raised the pull request to merge into master branch. PR got raised with multiple commits due to the way filter-branch works.

After the completion of PR, I noticed the file is not removed from master branch.

I can't directly run "git filter-branch" on master branch as I don't have force push permissions.

Is there a way to remove this File1.csv including its history (removing history is important due to the secret content in file) from master branch through a pull request?


Solution

  • Without force-pushing you can not rewrite history on the remote. Sorry, but what you are trying to do is not possible.