Reputation: 28430
At work we use a develop
branch for day-to-day work - new features, bug fixes, et al. When we are ready to release, we merge the devleop branch into master, tag, and release.
If we are needing to do a hotfix which needs to be released immediately, we create a branch off master
, apply changes, and merge accordingly (including merging master
back into develop
). There are no issues with what I have described so far.
I was just recently working on a small bug fix that was to be included in the next release. So created my usual branch off of develop
, made a few commits, and submitted a PR. Then a manager wanted the fix in today as a hotfix. OK - simple, I'll just rebase my work against master
and open the PR against master. However, running git rebase master
did not replay my work against the current HEAD commit on master. Instead, git told me that everything was "up to date". I then opened the PR against master, and my PR contained all new work from the develop
branch, not just my bug fix.
I was able to do an interactive rebase and drop all of the commits which shouldn't have been there, but this seems kind of tedious and error prone. Is there a more sane way of achieving this goal of rebasing against an older yet up-to-date branch?
Upvotes: 3
Views: 5428
Reputation: 45759
Instead of rebasing "against master
" (i.e. "with master
as the upstream" per the command you used), you needed to rebase your work --onto master
with the upstream set to develop
.
git rebase --onto master develop my_fix
Bear in mind this creates a new and untested code state; since hot-fixes are fast-tracked to production a special eye to testing it is warranted.
Upvotes: 2