0

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?

  • 1
    Short answer: You cannot change the history of the remote without force push permissions. – dan1st Jul 27 '20 at 21:14
  • 1
    You could contact the repository administrator but I would recommand you to invalidate those secrets. – dan1st Jul 27 '20 at 21:15
  • It doesn't have secrets but other important info which can't be invalidated. If I contact repo admin, is git filter-branch (as it raises multiple commits) the best option or we can try some other command. I will have to provide exact command to repo admin as the repo belongs to my team. – usercode-123 Jul 27 '20 at 21:19
  • 1
    Contact therepository administrator. – dan1st Jul 27 '20 at 21:19
  • But note that every user who pulled it has it and needs to remove it from their computer manually, too(e.g. by re-cloning the repository) – dan1st Jul 27 '20 at 21:20
  • all users local and branches are cleaned up. Guess I just need to reach out to repo admin with the exact command. Any recommendation on the command to use – usercode-123 Jul 27 '20 at 21:22
  • It seems ok, evrn though `filter-branch` is deprecated. – dan1st Jul 27 '20 at 21:24
  • You could also create a new (remote) branch (maybe in another repo) with your history and ask the admin to reset master to that branch – dan1st Jul 27 '20 at 21:25
  • Will master branch retain the history of my branch if reset is done? My requirement is to only remove history of file1.csv from master branch – usercode-123 Jul 27 '20 at 21:34
  • A reset changes the branch to point to another commit. This commit is part of the new history and will therefore only contain the new history (if done correctly). However, this will not effect other branches. – dan1st Jul 27 '20 at 21:36

1 Answers1

1

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

Ente
  • 2,301
  • 1
  • 16
  • 34