Our shop has a fairly rapid deploy cycle (1-2 weeks between when the code is written and when it's released). As such, after a bit of experimentation we've adopted the following pattern for our Git usage:
This style has a number of advantages for us: it makes it so the QA team is testing exactly what is going to go live, it makes it easy for us to put stuff in and take stuff out of QA, it keeps the code for a specific fix all nice and tidy in its own branch, etc.
However, several people here are concerned about our use of rebase (both to rebase the current pre-master in to the fix branch before merging that fix branch in to pre-master, and to rebase the pre-master branch to take out failed fixes). Their concern is that rebasing could potentially result in lost history, and as such we should rebase as infrequently as possible.
However, without rebasing the only alternative we've come up with is to make the pre-master branch a dead-end branch, used only for QA. This would make rebasing that branch safer, and when we're ready to release we'd re-merge the fix branches directly in to master. The problem with this approach though is that QA wouldn't actually be testing what's going live, and an improper merge conflict resolution (when merging the fixes in to master) could easily slip by them (unless they re-qa everything all over again). This is the main reason why we've stuck with our current approach, despite the rebasing concerns.
So, with that very long prelude out of the way, my actual question is ... well it's two-part:
In general, I would agree that without a good mechanism for keeping track of things that are in flight (which could be outside your SCM system itself, e.g., in your bug tracker), rebasing things as a rule could be dangerous.
There are (at least) 2+ very good resources on how to manage a release process using Git branches.
Git itself uses a "proposed updates" branch (called pu) that mirrors your pre-master branch. This branch consists of merges from various fix branches. This branch is intended for really unstable features that need to be tested and integrated. It can relatively freely be rebased and reset. (Again, each individual topic/feature branch is tracked outside of Git). Features are generally only merged once into pu and pu gets reset against something more stable very regularly.
More stable changes get merged into next for wider testing. Again, this is handled with merging, not rebasing. Your pre-master branch serves similar purpose to both next and pu. A feature might get merged multiple times into next, to incorporate additional feedback. Development still happens on the topic branch though.
When the topic branch is deemed stable enough, it is merged to master.
To help track what is going on, Git has a concept of "What's Cooking". Junio Hamano, the Git maintainer, has a script called cook that helps keep things straight for everyone and what state various topic branches are in.
Of course, there is no explicit QA process for Git; in your case, with a real QA team, you can do some combination of things.
--no-ff to explicitly track the branch provenance.pre-master branch by resetting and re-merging, or by reverting the merge commit, or by merging in a new fix that appeared on top of the old fix branch.master, create a new integration branch that directly merges in all of the successful fixes just once from each fix branch. You can verify that this tree is literally the code that QA tested (e.g., git diff integration pre-master is empty). Then merge the integration branch into master (again, using --no-ff to track who did it and when).pre-master from scratch by doing a git checkout pre-master; git reset --hard master, or you can do a presumably trivial merge back from master (resolving all conflicts in favor of master, e.g. git checkout pre-master; git merge -s recursive -X theirs master).pre-master.The differences here are mostly just to use the merges to help you keep track of what has been merged and when and by whom. The other nice thing about merges is that developers (and QA) will see fewer forced updates, and more just regular updates.
Again, the real thing to emphasize is that there must be something that is used to track what has been merged (or rebased) into a stable branch and tested successfully.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With