0

We started using GitHub as Source control in our project recently and we are using Feature branches to work on the features. Once we are done with our development, we merge it to the develop branch using pull request.

During the merge if there are conflicts, we resolve using the web editor. But during this process all the commits done on the file with conflicts get included as a part of the feature branch.

Does anyone know how can i avoid this and make sure the feature branch stays clean?

Anee
  • 463
  • 9
  • 26
  • `commits done on the file` ... commits in Git are not done on a file. A commit conceptually represents a snapshot of _every_ file in your repository. When you stay up to date by merging a source branch into a feature branch, and then vice-versa, things don't stay "clean," they get messy. This is how merging works. – Tim Biegeleisen May 23 '18 at 06:27

1 Answers1

1

You should only merge the feature branch into the develop branch (not the other way around). Then resolve the conflicts right there in the develop branch itself.

  1. git checkout develop
  2. git merge feature-branch
  3. resolve conflicts in develop
  4. git push

Note: If you are not too comfortable with the conflict resolution process, then best to create a 'develop-merge' branch, then merge the feature branch into it before creating a cleaner pull request for merging the new 'develop-merge' into 'develop' branch.

This way the develop branch will include all the features at the same time the feature branch won't be convoluted.

J K
  • 754
  • 6
  • 12
  • If there's a pull request created with conflicts, you recommend not to fix the conflicts in the web editor and instead resolve it in command prompt? – Anee May 23 '18 at 06:48
  • Yes, resolve it either in terminal or even IDE. But its important to do it in the branch you are merging to (not from) – J K May 23 '18 at 19:54
  • why is it merge on develop, not on feature-branch? – Oğulcan Karayel Sep 27 '22 at 19:30