git filter-repo rewrote all branch histories — branches now show 5500+ commits ahead/behind main #190689
Replies: 2 comments
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
This is expected behavior after What happenedWhen you ran How to fix itOption 1: Force-push all branches (if you have few collaborators)Every collaborator needs to re-clone or hard reset: # For each stale branch, reset to the rewritten version
git fetch origin
git checkout <branch-name>
git reset --hard origin/<branch-name>If some branches were already merged into main, they can be safely deleted since their changes are already in the rewritten main. Option 2: Delete stale branchesIf those branches are already merged (their changes exist in main), just delete them: # List merged branches
git branch -r --merged origin/main
# Delete them
git push origin --delete branch-nameOption 3: Rebase remaining active branchesFor branches with ongoing work: git checkout feature-branch
git rebase origin/main
git push --force-with-lease origin feature-branchAbout the secretSince the .npmrc with secrets was already pushed and visible in the PR, the secret is compromised regardless of the history rewrite. Make sure you've rotated the credentials - removing from git history prevents future exposure but doesn't invalidate what was already seen. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
🏷️ Discussion Type
Bug
💬 Feature/Topic Area
Issues
Body
Issue: Repository History Diverged After
git filter-repoand Partial Force PushWhat Happened
I accidentally committed a
.npmrcfile containing secrets and pushed it via a PR. To remove the secret from the repository history, I usedgit filter-repoto completely strip the file from all commits.Commands Used
Beta Was this translation helpful? Give feedback.
All reactions