git rebase master

and you get conflicts. Here’s how to proceed:

1. fix conflicts

Look for CONFLICT and edit the file mentioned. Note: the path is to the root of the git repo not where you are currently

2. git add <conflicted files>

3. git rebase –continue

Once you’ve merged and do a git status I got:

This would be because I’d already pushed my feature branch. i.e. you’re changing the history of all those commits by doing the rebase

The solution is, assuming you’re the only one using your feature branch, is to force push.

A trick to make this less dangerous is to use git push --force-with-lease rather than git push -f. This way if someone did get hold of your feature branch and push a change it would fail instead of overwriting the new commit.

However the golden rule is – don’t use rebase on public branches. If you’ve pushed then

 

More here:

https://stackoverflow.com/questions/19016698/git-branch-diverged-after-rebase

and here: https://stackoverflow.com/questions/34678950/git-branch-has-diverged-after-rebase-so-why-rebase/34679616

and https://www.reddit.com/r/git/comments/6jzogp/why_am_i_force_pushing_after_a_rebase/

 

Note: If everything goes wrong:

git rebase –abort

Leave a Reply

Your email address will not be published. Required fields are marked *