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 
5
  • I assume you are using interactive rebase to squash commits. Are you sure the conflicts are not genuine? Commented Jun 11, 2014 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) Commented Jun 12, 2014 at 3:44
  • 1
    You did not show us the commands that you use to merge and rebase your branches. Those would help. Commented Jun 12, 2014 at 5:21
  • (in my branch) git merge master, and git rebase --interactive master Commented Jun 13, 2014 at 17:07
  • possible duplicate of Rebase a merge commit Commented Oct 29, 2014 at 12:55

1 Answer 1

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 
Sign up to request clarification or add additional context in comments.

1 Comment

Im sorry, but not sure what is different between that and git rebase master. Could you explain the main difference?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.