Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to Push After bfg Cleaner

Followed these steps to remove some content from my repository.

However, when I did a git push, I got the below message:

Writing objects: 100% (28/28), 6.72 KiB | 1.34 MiB/s, done. Total 28 (delta 18), reused 18 (delta 9) remote: error: denying non-fast-forward refs/heads/master (you should pull first) remote: error: denying non-fast-forward refs/heads/multiplicity_refinement (you should pull first) To ssh://path_to_repo/repo_name.git ! [remote rejected] master -> master (non-fast-forward) ! [remote rejected] multiplicity_refinement -> multiplicity_refinement (non-fast-forward) error: failed to push some refs to 'ssh://path_to_repo/repo_name.git'

like image 987
Di Yao Avatar asked Sep 15 '25 03:09

Di Yao


1 Answers

By default, Git refuses to push any commits to an existing branch if doing so would lose commits already pushed. When you use BFG Cleaner or any other tool that rewrites your history, the commits you've made are rewritten and appear different from the existing commits (which they are). If you're sure you want to push those changes anyway, you'd need to use the --force flag: git push --force origin master.

You can run git push --help to see more information about --force and why it's necessary.

like image 144
bk2204 Avatar answered Sep 17 '25 18:09

bk2204