We use the following git workflow at my company when coding up a new story:
- Create a topic branch off of master (production/stable)
- Create as many commits as desired to implement feature.
- do a git merge --squash of that topic branch onto the qa branch.
- QA people review.
- If good, the code is merged into the ua branch. If the User Acceptance team blesses it, it gets merged to master and ultimately deployed.
- If it fails review, the developer needs to fix. Essentially restarting the process at step 2.
Note: It can be up to two weeks from the point code is merged to qa branch and the time qa rejects/accepts it.
If there are no issues, then the code eventually makes it into master. However, I'm seeking best practices for when QA finds an issue and you have to fix it. What I'd like is to end up with a qa branch looking as "pristine" as possible.
As I see it, here are the options:
- Revert the original squashed commit in qa branch, rebase topic branch off of qa, fix your code in the topic branch, merge it into qa again. Problem: leaves icky revert commit around.
- Delete existing topic branch, recreate it from qa branch, create a simple commit to fix problem, merge back into qa. Problem: spreads code changes for feature across commits distinct in time and place.
- Do away with squashed merges to qa, rebase individual commits from qa to existing topic branch, fix with another commit, merge into qa. Problem: multiple commits make it difficult to track changes as they move to ua branch and then to master.
Question: Is there a best practice for moving multiple commits for a single feature through multiple long-lived branches (master -> topic -> qa -> ua -> master) when merged code may need to be fixed?