Pushing after a rebase
suggest changeSometimes you need to rewrite history with a rebase, and git push rejects the update because the remote branch is not an ancestor of your rewritten commits.
This can be solved with a git push --force, but consider git push --force-with-lease, indicating that you want the push to fail if the local remote-tracking branch differs from the branch on the remote, e.g., someone else pushed to the remote after the last fetch. This avoids inadvertently overwriting someone else’s recent push.
Note: git push --force - and even --force-with-lease for that matter - can be a dangerous command because it rewrites the history of the branch. If another person had pulled the branch before the forced push, their next git pull can fail because their local history and the remote history have diverged. This may cause the person to have unexpected errors. With enough looking at the reflogs the other user’s work can be recovered, but it can lead to a lot of wasted time. If you must do a forced push to a branch with other contributors, try to coordinate with them so that they do not have to deal with errors.