To push the changes to the branch after a rebase, you need to force push your commits using the -f
or --force
flag in the git push
command on Git.
It can be done like this,
# Push commits to branch after git rebase
git push origin -f FEATURE_BRANCH_NAME
-
This is because something has changed in the remote branch and the commit history is different for both the remote and your local branch.
-
If you try to push the local changes then the git will reject it by saying with a message like
the tip of your current branch is behind its remote counterpart
. Doing a force push to the local brach solves the problem. -
Don't be afraid of it. This is a good approach if you are the only one working on the same branch. 👍🏽
I hope this answer helped you! Cheers 😃