Force Pushing
suggest changeSometimes the remote branch cannot fast-forward to your local branch (it is not an ancestor of your tip). A normal push is rejected. A force push still updates the remote.
git push -f
or
git push --force
Important notes
This will overwrite any remote changes and your remote will match your local.
Attention: Using this command may cause the remote repository to lose commits. Moreover, it is strongly advised against doing a force push if you are sharing this remote repository with others, since their history will retain every overwritten commit, thus rendering their history out of sync with the remote repository.
As a rule of thumb, only force push when:
- Nobody except you pulled the changes you are trying to overwrite
- You can force everyone to clone a fresh copy after the forced push and make everyone apply their changes to it (people may hate you for this).
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents