I’m a purist. The stable and persistent main branch, regardless of what you want to call it, should always and only ever be exactly the same as the code that’s currently deployed to the production server. Generally the only exception is for the short duration between a push and deployment under normal circumstances.
But every job I’ve ever had, there’s at least one maverick who knows git way better than anybody else and is super advanced, so they do their own thing which is totally better in a million different ways but essentially fucks everybody else over. And I’m not even here to say they aren’t smarter than the rest of us and I’m sure that somehow their process is better than what we currently do. But with version control, my anecdotal experience has been that the most important things for running smoothly are: consistency and having everybody on the same page. Process doesn’t need to be perfect, maximally efficient, bleeding edge, etc to achieve that.
I can see that working well especially in a project where you can push to production fairly often, our project only has 2 moments every year where new features can be pushed to production. The exception is major bugs and security patches.
Anyways our main branch is always ahead of production. New features are branched of main, and can only be merged when the entire test suite passes, this is unit tests, integration tests and automated functional tests take about 5 hours (this project has been live since 2010).
We make release branches so we can always use them for bugfixes etc.
I think it kind of depends on a project what works best. For us a main branch that is only updated twice a year wouldn’t be the best way, I think.
What are the maverick git workflows? When I had a web developer job, it all seemed pretty straightforward and I can’t imagine doing it some other way and it being a good idea.
Okay, but be advised: this is how we start fights. Depending on where you’re coming from, everyone else is doing it wrong. Keep that in mind. That said, I want to have a discussion with you and others, if possible.
If we assume that a GitHub PR, or GitLab MR, workflow is “typical”, then the oddballs I know of are:
Geritt - It endorses a unit of review/work that is always exactly one commit. I have some strong opinions about why this is a thing, why it’s not great, why you shouldn’t if you’re not Google, and how Google got here, but that’s a whole other discussion. It’s a super-polarizing approach to Git in general.
Gitflow - takes the usual branching strategy of MR/PR work and dials it up to 11. This too is polarizing, as the added complexity can be a bit much for some folks.
IMO, a lot of the trouble we run into with Git is largely due to training problems. Also, one has to architect the git space to fit the company, culture, and engineering needs at hand. This means planning out what repositories you need, how you’re going to solve CI/CD, what bar for code review is needed, how to achieve release stability, and how to keep the rate of change steady and predictable. To do any of that, everyone needs to learn a bevy of git commands to do this well, and not enough companies bother to teach them.
Gitflow is the usual branching strategy. It’s not dialed up to 11, it only specifies precisely what to merge to where and from where.
The real mavericky thing is when someone uses cherrypicking in combination with squash merges thus breaking branch compatibility.
I have been the git specialist in the last few teams, and thus I’m the one who has to clean that up every time. Not because it’s hard, but because nobody can be bothered to actually learn git.
Edit: The other thing is to use rebases instead of merges. Yes, they make for a much nicer git history, but they also tend to break everything in the process when the rebase is sufficiently large.
But every job I’ve ever had, there’s at least one maverick who knows git way better than anybody else and is super advanced
Pretty sure that’s me at my job, but I take your approach too.
I just have lousy coworkers who keep a bunch of stale branches open with no real maintenance plan. Thankfully I kind of work in my own bubble and generally avoid that jungle
I’m a purist. The stable and persistent main branch, regardless of what you want to call it, should always and only ever be exactly the same as the code that’s currently deployed to the production server. Generally the only exception is for the short duration between a push and deployment under normal circumstances.
But every job I’ve ever had, there’s at least one maverick who knows git way better than anybody else and is super advanced, so they do their own thing which is totally better in a million different ways but essentially fucks everybody else over. And I’m not even here to say they aren’t smarter than the rest of us and I’m sure that somehow their process is better than what we currently do. But with version control, my anecdotal experience has been that the most important things for running smoothly are: consistency and having everybody on the same page. Process doesn’t need to be perfect, maximally efficient, bleeding edge, etc to achieve that.
I can see that working well especially in a project where you can push to production fairly often, our project only has 2 moments every year where new features can be pushed to production. The exception is major bugs and security patches.
Anyways our main branch is always ahead of production. New features are branched of main, and can only be merged when the entire test suite passes, this is unit tests, integration tests and automated functional tests take about 5 hours (this project has been live since 2010).
We make release branches so we can always use them for bugfixes etc.
I think it kind of depends on a project what works best. For us a main branch that is only updated twice a year wouldn’t be the best way, I think.
What are the maverick git workflows? When I had a web developer job, it all seemed pretty straightforward and I can’t imagine doing it some other way and it being a good idea.
Okay, but be advised: this is how we start fights. Depending on where you’re coming from, everyone else is doing it wrong. Keep that in mind. That said, I want to have a discussion with you and others, if possible.
If we assume that a GitHub PR, or GitLab MR, workflow is “typical”, then the oddballs I know of are:
IMO, a lot of the trouble we run into with Git is largely due to training problems. Also, one has to architect the git space to fit the company, culture, and engineering needs at hand. This means planning out what repositories you need, how you’re going to solve CI/CD, what bar for code review is needed, how to achieve release stability, and how to keep the rate of change steady and predictable. To do any of that, everyone needs to learn a bevy of git commands to do this well, and not enough companies bother to teach them.
Gitflow is the usual branching strategy. It’s not dialed up to 11, it only specifies precisely what to merge to where and from where.
The real mavericky thing is when someone uses cherrypicking in combination with squash merges thus breaking branch compatibility.
I have been the git specialist in the last few teams, and thus I’m the one who has to clean that up every time. Not because it’s hard, but because nobody can be bothered to actually learn git.
Edit: The other thing is to use rebases instead of merges. Yes, they make for a much nicer git history, but they also tend to break everything in the process when the rebase is sufficiently large.
Pretty sure that’s me at my job, but I take your approach too.
I just have lousy coworkers who keep a bunch of stale branches open with no real maintenance plan. Thankfully I kind of work in my own bubble and generally avoid that jungle