I have a question about the git merge workflow.
I have worked on a ticket and finished it, added a merge request into the main branch and now comes in my next ticket I should work on.
Is it a good practice to branch off the main branch or the last ticket's branch for working on the second ticket, while I am still waiting for review and merge approval of the first ticket?
Branching off the main will leave out all the changes in the ticket-1-branch, while branching off ticket-1-branch still needs approval.
Is there any rough guideline as how to proceed in such situation?
CodePudding user response:
If the next ticket is not dependent on the one that you've worked earlier (those changes are not needed for the next ticket) then the best approach would be just creating another branch from the main
.
But if the ticket is dependent, then you can create another branch from your current branch (of the previous ticket) and continue working on that.
And as soon as the previous branch is merged just rebase your new branch with main
(or cherry pick the new commit if needed).
CodePudding user response:
My consolidated approach is to solve the second issue starting from the master
branch.
In the meanwhile, if the first task was approved, I merge it into the second branch, and I validate it again.
The reason is that you cannot work on a code which may be wrong.
CodePudding user response:
To add to given answer, I would not touch branch that is under code review.
Then it may be merged with some not working code or pull requests may be harder to review.
So I would create new branch off from the main master
branch and work on new things there.