Reputation: 5882
I'm working on 2 branches representing different features. Here are the steps I did.
git push origin feature_b
throws: Updates were rejected because the tip of your current branch is behind its remote counterpart.I don't understand why local feature_b branch would be behind the upstream branch. Note: I'm the only person working on this branch and the last person to commit to dev.
Upvotes: 2
Views: 1464
Reputation: 1846
Since you rebased feature_b onto the latest changes from dev, you effectively changed the history of feature_b so now feature_b and origin/feature_b have diverged. You'll need to git push origin feature_b --force
to get the change to origin.
The problem is that git push
assumes that origin/feature_b can be fast-forwarded to your local branch. Since you rebased the local branch, the fast-forward is no longer possible.
With the --force
option, you're telling the remote branch to ignore it's current state and overwrite it with your local branch. So git push --force origin feature_b
simply overrides origin/feature_b with local feature_b.
Note that the --force
option can cause the remote repository to lose commits, so use it with care.
Upvotes: 4