I find myself running into a workflow where I do the following:
- Create a feature branch ("
foo") off of ourdevelop("master") branch - Work, work , work...
- Submit a pull request for
foo - While waiting for approval, start work on a related feature...:
- Create another feature branch ("
bar") off of my previousfoobranch - ...because the work is so closely tied that I couldn't progress directly from
develop+ I can't wait for reviews -- they sometimes take over a week - Submit a pull request for
bar - Get approval for
fooand merge it intodevelop - [we use squash-merges]
- People are reviewing
bar, there are comments, maybebaris even approved by now - Now I rebase
baras follows: git checkout bargit rebase --onto develop foogit push --force origin bar- Get approval for
barif not already approved by now, and merge it intodevelop
This works as expected, but it re-writes history, and is frowned upon because people have already been looking at bar, and there's no way to really know what I did when I force-pushed.
If I try to merge without rebasing, I get all kinds of merge conflicts. It's like develop is trying to "undo" my changes in bar.
My question is:
Is there an equivalent git merge workflow to git rebase --onto??? Something like:
git checkout bargit merge ??? develop ??? foo
Is there some trick like... maybe I merge foo back onto bar, or some trick with setting the upstream? I'm fishing here...
Thanks!
EDIT: Another thing... even this process can be a PITA if I have multiple commits in bar. I'll usually merge-in foo to bar at the end, so there's definitely no conflicts between them. But there might be a conflict between an early commit in bar and the latest foo. So I have to do a git rebase -i bar on bar and squash it down to one commit before I do the git rebase --onto develop foo... Not great for preserving history... because now I'm squashing out comment commits, and such. So sometimes I use another alternative:
git checkout bargit reset foogit add stuffgit commit -m "One commit of foo-bar delta"
Again, grimy -- all the comment commit history is lost...