Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Remove a File from GitHub Repo and History, Including Pull Requests? #520

Open
genieai-vikas opened this issue Sep 17, 2024 · 1 comment

Comments

@genieai-vikas
Copy link

I want to remove a sensitive file mongodb.key from my GitHub repository, including its history. I followed these steps:

git clone --mirror https://github.com/test-co/github-action-poc
bfg --delete-files mongodb.key github-action-poc.git
cd github-action-poc.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push --force

However, when I try to push, I’m encountering the following errors:

 ! [remote rejected]     refs/pull/7/head -> refs/pull/7/head (deny updating a hidden ref)
 ! [remote rejected]     refs/pull/8/head -> refs/pull/8/head (deny updating a hidden ref)
 ! [remote rejected]     refs/pull/9/head -> refs/pull/9/head (deny updating a hidden ref)
error: failed to push some refs to 'https://github.com/test-co/github-action-poc'

It seems the pull request (PR) references are causing issues. How can I remove the mongodb.key file from the repository, including PRs, and successfully push my changes? What is the correct approach for this?

Thanks in advance!

@glebsts
Copy link

glebsts commented Sep 18, 2024

You can grep this "remote rejected" from github issues and see that technically the valid way is to create a new repo and push mirror clone edited with BFG to this new repo. Github and Bitbucket do have those internal refs and don't want you to change them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants