In merging my changes against an upstream master, I frequently find myself doing the following:
git checkout somefeature
git checkout -b integration
git rebase master # resolving conflicts along the way
git checkout somefeature
git merge integration # or rebase, doesn't matter in this example
I'll often find that merging the integration branch back into my feature branch fails do to some conflicts. The first question I have is, "why is this happening if my integration branch is a descendent of somefeature and I've already resolved conflicts against the upstream master?"
If you're wondering why I'm using an integration branch to begin with, it's to prevent polluting my current branch with a half-failed merge.
My current workaround is to do this:
git checkout integration
git branch -f somefeature # overwrite the branch
The problem now is that I can't push my changes back to a remote branch:
git push origin somefeature
! [rejected] somefeature -> somefeature (non-fast forward)
So now I have to remove the remote branch and re-push my changes. This can't be the optimal way to do this, so I'm wondering, "what's the best way to overwrite a branch and push the changes to a remote branch?"