0

Merge conflict after these steps:

  1. Feature branch created from develop branch.
  2. Commit A created on feature branch.
  3. Few commits merged to develop branch from other feature branches.
  4. Develop branch merged to feature branch - creating a merge commit.
  5. Until step 4, changes are made either in remote/local repository and pulled/pushed. Now, some more changes happened on remote develop branch which caused merge conflict (seen on web interface), for pull request from feature branch to develop branch.

Merge conflict resolution steps:

  1. Revert commit A in feature branch in local repository.
  2. Take latest changes from develop to local repository and merge to feature branch. This merge step doesn't cause any merge conflict as the changes on feature branch are reverted above step.
  3. Cherry pick the commit A onto feature branch, which presents merge conflict. Resolve the merge conflict. It is easy to resolve this merge conflict, as you'll be looking at the changes you intended to put in the feature branch.

Resolutions steps 1-3 are performed in local repository and pushed to remote.

Question: Merge conflict resolution steps work fine, if merge from develop to feature (merge commit - step 4) is not performed. Do these resolution steps present any issues, given after commit A, merge commits are performed on feature branch.

The query is not regarding how to resolve merge conflict. This is regarding the steps mentioned give any trouble, given after commit A, merge commit is also performed on feature branch.

Update - Answer: The above process works without any problem. In the question, after commit on feature branch(step 2), merge commit from develop branch to feature branch is done(step 4). The merge conflict resolution steps work fine, given, in the merge commit done on step 4, there are no merge conflicts resolved.

If there are merge conflicts resolved on step 4, changes meant for feature branch are in commit A as well as in merge commit(step 4). In this scenario, the merge conflict resolution steps(1-3) below are not sufficient. The merge resolution steps (1-3) should be followed from the beginning (from the time feature branch is created), if any merge conflict happen on the feature branch.

Shashi
  • 109
  • 1
  • 2
  • 9

1 Answers1

0

AFAICS, you want to keep the changes in develop and the changes in feature. I would prefer a rebase in this case since I want develop as the base for my feature branch and I just wish commit A from feature to be put on top of develop.

git checkout develop
git pull origin develop
git checkout feature
git rebase develop

# If any conflicts are here, you HAVE to look up what part of code you'd like to keep and what to discard.

This will not ditch you.

unixia
  • 3,291
  • 1
  • 13
  • 20
  • Rebase is not usable as commit A, and a merge commit are already pushed to remote. – Shashi Feb 02 '18 at 11:29
  • I see. You could then do a `git reset `, brig both the branches to their earlier stable states and then rebase. It would be good to do this in different local branches and then check the diff with remote, you'll get to know if merge led to some loss of data. – unixia Feb 02 '18 at 11:35