I realize this might be a common problem, but so far I was not able to find a good solution via google/so search.
I have the following git branch setup:
$ git branch -a
* my_feature
main
remotes/origin/HEAD -> origin/main
remotes/origin/colleagues_feature
remotes/origin/my_feature
remotes/origin/main
With the PR of my_feature
pretty much done, I wanted to rebase it on main (where a colleages feature PR was merged in the meanwhile) and then finally implement some needed additions to let my colleages feature work together with mine.
I guess what I should have done was:
1. Commit my changes
2. git checkout main
3. git pull
4. git checkout my_feature
5. git rebase main
6. git push
But what I did was:
1. Commit my changes
2. git push
3. git rebase main (with main being up to date with remote/origin)
4. git push
The last step now fails due to merge conflicts, git status prints the following message:
$ git status
On branch my_feature
Your branch and 'origin/my_feature' have diverged,
and have 17 and 5 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
After rebasing my local branch looks as expected, everything as I want/need it. I understand why there are now merge conflicts with the remote branch, but in my mind I should just have to rebase it as well.
Question is how to do this correctly?