My team is running into an issue with a workflow that used to work fine for me. Or at least I remember it working fine.
// TL;DR
After rebasing the local version of feature-branch with the local main branch, I'm unable to push the local feature-branch to the existing remote feature-branch. How does one deal with this? Or is there a better workflow when creating pull requests?
// Here's the full scenario:
- To start building my feature I run
git checkout -b feature-branchwhile on themainbranch. - The above puts me in the
feature-branch. I build my feature and then rungit push -u origin feature-branchto push the branch to github. - I create a pull request on github and have others make comments. I make some changes to local
feature-branchand rungit pushto update the remote branch. - My pull request is approved and I'm ready to rebase and merge w/
mainbranch, BUT there have been other commits to themainbranch since my pull request went live. Github is unable to do the rebase and merge as there are conflicts. Hence I need to rebase my changes on top of themainbranch locally, fix and then push. The way I do this is:- Locally, I switch to
mainbranch and rungit pull. This pulls in all the latest changes frommain. - Locally I switch to my
feature-branchand then rungit rebase main. This rebases my changes on top of the new changes in themainbranch. I fix conflicts during the rebase. - I try to run
git pushto update the remotefeature-branchbut this errors saying the remote and local branch have diverged. I thought I used to do this all the time but maybe I'm mistaken. What is the typical/good/correct workflow for this?
- Locally, I switch to
Thank you in advance for your help!