1

Im a bit confused about these scenarios:

  1. I have a task.
    I create feature branch, make work here.
    And then I create Pull Request to release-test branch.
    In order to avoid conflicts, first I have to update my feature branch. So I have to merge release-test into feature.
    But in this case, in my Pull Request I will have a lot of merged commits which I don't want to have. I want only my feature branch commits in PR.
    What should I do in this situation?

  2. I pushed my feature branch and then conflict appears in PR. What are my next steps?
    I tried to revert to the last commit, made compare with release-test branch, then force push. Is this a good practice?

P.S. I'm using Intellij Idea if this would help

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

1

In order to avoid conflicts, first I have to update my feature branch. So I have to merge release-test into feature.

Don't: you should always merge from specific to integration branches, not the reverse.

  • Your feature branch is a specific branch (specific for a given task you are isolating in its own branch)
  • release-test is an integration branch (where multiple branches come to be merged)

If you need to update your feature branch compared to release-test, rebase it:

 cd /path/to/local/repo
 git switch feature
 git fetch
 git rebase origin/release-test
 # resolve potential conflict there
 git push --force

That will guarantee there won't be any conflict in your PR (automatically updated after the push --force), since your feature branch will only add new commits on top of the most recent remote release-test branch.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250