I am trying to integrate git-rebase into my workflow. I have a feature branch my-feature
that was branched from develop
. In order to have the most recent changes from develop
my plan is that I every morning I should (while on my-feature
) git rebase develop
. This works pretty well, however when I try to push my feature branch
$ git push origin my-feature
I get this error:
! [rejected] my-feature -> my-feature (non-fast-forward)
error: failed to push some refs to 'git@some-domain:some-directory/my-repo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
I am thinking that git has given shared commits new local SHAs as the logs for origin/my-feature
and local my-feature
show different ones for the same commit messages. In fact, doing a git pull
like it suggests gives me conflicts to reconcile. But I am the only one using this feature branch, so the conflicts are ..with myself?
I was aware that interactive rebase will assign new SHAs when commits are squashed or removed. However I thought what I was doing was a pretty standard workflow for integrating a remote develop
branch for longer-running features.
How can I use the rebase functionality to integrate a remote dev branch on a long running feature without introducing conflicts when I go to push my feature?
For clarity my process was basically:
- On
develop
- Checkout new branch
my-feature
- Do work on
my-feature
- Push code to
origin/my-feature
(success) - Do more work on
my-feature
- While on
myfeature
,$ git rebase develop
(success) git push origin my-feature
<-- ERROR (above)
Switching to develop
and git rebase my-feature
gives me a few expected conflicts I need to fix, but no errors.
Edit:
Also, I am aware I can use --force
, however I can foresee sharing a feature branch so don’t think introducing that flag as part of the workflow is a great solution.