0

I know this has been asked a lot, but I have not really seen a good answer. Here is what I am looking for.

We do pull-requests in Stash.
We want the history to show one commit per feature (stash merges into master, so there is one merge, one commit). Work is done in feature branches, and commits happen often. Git rebase master is used to rewrite the history to get one commit.

The issue I am facing is that when a few features go into master, I git merge my feature branch with master, and add a few more commits. When my code is ready for review I rebase and now git thinks there are conflicts.

What I want the history to really look like is the same as doing

$ git diff master > feature.patch
$ git checkout master
$ patch -p1 < feature.patch
$ git commit -am "[Bug-1234] Desc"

Is there any way to do this with rebase? Basically accept all as they are in HEAD.

EDIT:

Here are the commands that put me in this spot

(feature/awesome) $ git merge master #resolve conflicts
(feature/awesome) $ git rebase --interactive master
ekaqu
  • 2,038
  • 3
  • 24
  • 38
  • I assume you are using interactive rebase to squash commits. Are you sure the conflicts are not genuine? – Matt Jennings Jun 11 '14 at 23:50
  • Correct, using interactive to squash them. The conflicts are not genuine (they might be from a history perspective, not from a code perspective), the code in the branch is what is wanted, all merges are basically just --ours which works (if I commit each file one by one) – ekaqu Jun 12 '14 at 03:44
  • 1
    You did not show us the commands that you use to merge and rebase your branches. Those would help. –  Jun 12 '14 at 05:21
  • (in my branch) git merge master, and git rebase --interactive master – ekaqu Jun 13 '14 at 17:07
  • possible duplicate of [Rebase a merge commit](http://stackoverflow.com/questions/9013411/rebase-a-merge-commit) – sschuberth Oct 29 '14 at 12:55

1 Answers1

2

What happens in the default rebase master case is that all commits since the merge-base of master and your feature branch get replayed and some of those conflict with the squashed commits that have already been applied.

However if you know the last commit that was merged from your feature branch into master, then you can apply only the commits after LASTCOMMIT on your feature_branch.

git rebase --onto=master LASTCOMMIT feature_branch
Michael Anderson
  • 70,661
  • 7
  • 134
  • 187
  • 1
    Im sorry, but not sure what is different between that and git rebase master. Could you explain the main difference? – ekaqu Jun 12 '14 at 03:45