Skip to main content
Commonmark migration
Source Link

I think the part of your question that is an anti-pattern is the use of a single shared master branch. However, if you were to include a develop branch in addition to the master branch and then use stashes to deal with your own context switches in the develop branch, that would not be an anti-pattern, and it very closely mirrors some of the workflow describe by organizations like Etsy and Facebook.

That having been said, @Greg Burghardt's answer above is a bit too favourable to the so-called git-flow or feature-branch work flow. I used to advocate for a similar strategy but after realizing that it adds unnecessary complexity and creates a false sense of security, I no longer do. It's also a holdover from the days of non-decentralized version control systems like subversion.

Firstly since Git is a decentralized version control system unlike subversion, a developer's local repository is essentially a giant branch of the code in and of itself. What an individual develop does locally doesn't and shouldn't have an impact on the other team members unless broken or buggy code is pushed up to any shared branches in a shared repository.

The rebase command, however, can damage the history of branch when there is a merge conflict in one of the replayed commits. From http://ryantablada.com/post/the-dangers-of-rebasing-a-branch

The rest of the rebase goes along smoothly, tests all seem to pass. A PR is made.

 

And then some more code is written that relies on the commentsForAllPosts property and everything is broken. But who do we go and ask for help? git blame shows that line of code has only been written by the server side engineer and he throws up his hands.

 

Now your front-end engineer is out on vacation, sick leave, or who knows. No one can figure out what that code should look like!

 

Rebase has killed the team's ability to look at the history to find what went wrong because any merge conflicts on the child branch are killed and the original code is lost forever.

 

If this same merge conflict came up and merge was used, the blame would show that that line of code had been touched in the merge process, the commit on the parent branch, and the commit on the child branch. Some toying around with the three permutations and you can get the original intent back into the code base and working without a ton of head scratching a finger pointing. And all you really had was another commit

Furthermore, a multiple branching model presupposes that no two branches could ever contain interdependent code changes. When that does inevitably occur, the developer now has to juggle yet more branches to work efficiently.

The fundamental anti-pattern that I see is not related to branches vs. stashes, but rather more about the kinds of problems that some very smart people have been talking about for a while now: do you have confidence in your code via the use of unit tests and a good architecture? Are you able to make incremental changes to your code such that your developers can reason about changes easily and understand what a change will do? Do your developers even run through new code once to see if it actually works? (Yes I have seen this before).

If the answer to those questions is no, then it doesn't really matter how many branches you have-- developers will say that code is ready, working, and fit for production when it really isn't, and no number of branches will help you when that code goes up to production anyway.

I think the part of your question that is an anti-pattern is the use of a single shared master branch. However, if you were to include a develop branch in addition to the master branch and then use stashes to deal with your own context switches in the develop branch, that would not be an anti-pattern, and it very closely mirrors some of the workflow describe by organizations like Etsy and Facebook.

That having been said, @Greg Burghardt's answer above is a bit too favourable to the so-called git-flow or feature-branch work flow. I used to advocate for a similar strategy but after realizing that it adds unnecessary complexity and creates a false sense of security, I no longer do. It's also a holdover from the days of non-decentralized version control systems like subversion.

Firstly since Git is a decentralized version control system unlike subversion, a developer's local repository is essentially a giant branch of the code in and of itself. What an individual develop does locally doesn't and shouldn't have an impact on the other team members unless broken or buggy code is pushed up to any shared branches in a shared repository.

The rebase command, however, can damage the history of branch when there is a merge conflict in one of the replayed commits. From http://ryantablada.com/post/the-dangers-of-rebasing-a-branch

The rest of the rebase goes along smoothly, tests all seem to pass. A PR is made.

 

And then some more code is written that relies on the commentsForAllPosts property and everything is broken. But who do we go and ask for help? git blame shows that line of code has only been written by the server side engineer and he throws up his hands.

 

Now your front-end engineer is out on vacation, sick leave, or who knows. No one can figure out what that code should look like!

 

Rebase has killed the team's ability to look at the history to find what went wrong because any merge conflicts on the child branch are killed and the original code is lost forever.

 

If this same merge conflict came up and merge was used, the blame would show that that line of code had been touched in the merge process, the commit on the parent branch, and the commit on the child branch. Some toying around with the three permutations and you can get the original intent back into the code base and working without a ton of head scratching a finger pointing. And all you really had was another commit

Furthermore, a multiple branching model presupposes that no two branches could ever contain interdependent code changes. When that does inevitably occur, the developer now has to juggle yet more branches to work efficiently.

The fundamental anti-pattern that I see is not related to branches vs. stashes, but rather more about the kinds of problems that some very smart people have been talking about for a while now: do you have confidence in your code via the use of unit tests and a good architecture? Are you able to make incremental changes to your code such that your developers can reason about changes easily and understand what a change will do? Do your developers even run through new code once to see if it actually works? (Yes I have seen this before).

If the answer to those questions is no, then it doesn't really matter how many branches you have-- developers will say that code is ready, working, and fit for production when it really isn't, and no number of branches will help you when that code goes up to production anyway.

I think the part of your question that is an anti-pattern is the use of a single shared master branch. However, if you were to include a develop branch in addition to the master branch and then use stashes to deal with your own context switches in the develop branch, that would not be an anti-pattern, and it very closely mirrors some of the workflow describe by organizations like Etsy and Facebook.

That having been said, @Greg Burghardt's answer above is a bit too favourable to the so-called git-flow or feature-branch work flow. I used to advocate for a similar strategy but after realizing that it adds unnecessary complexity and creates a false sense of security, I no longer do. It's also a holdover from the days of non-decentralized version control systems like subversion.

Firstly since Git is a decentralized version control system unlike subversion, a developer's local repository is essentially a giant branch of the code in and of itself. What an individual develop does locally doesn't and shouldn't have an impact on the other team members unless broken or buggy code is pushed up to any shared branches in a shared repository.

The rebase command, however, can damage the history of branch when there is a merge conflict in one of the replayed commits. From http://ryantablada.com/post/the-dangers-of-rebasing-a-branch

The rest of the rebase goes along smoothly, tests all seem to pass. A PR is made.

And then some more code is written that relies on the commentsForAllPosts property and everything is broken. But who do we go and ask for help? git blame shows that line of code has only been written by the server side engineer and he throws up his hands.

Now your front-end engineer is out on vacation, sick leave, or who knows. No one can figure out what that code should look like!

Rebase has killed the team's ability to look at the history to find what went wrong because any merge conflicts on the child branch are killed and the original code is lost forever.

If this same merge conflict came up and merge was used, the blame would show that that line of code had been touched in the merge process, the commit on the parent branch, and the commit on the child branch. Some toying around with the three permutations and you can get the original intent back into the code base and working without a ton of head scratching a finger pointing. And all you really had was another commit

Furthermore, a multiple branching model presupposes that no two branches could ever contain interdependent code changes. When that does inevitably occur, the developer now has to juggle yet more branches to work efficiently.

The fundamental anti-pattern that I see is not related to branches vs. stashes, but rather more about the kinds of problems that some very smart people have been talking about for a while now: do you have confidence in your code via the use of unit tests and a good architecture? Are you able to make incremental changes to your code such that your developers can reason about changes easily and understand what a change will do? Do your developers even run through new code once to see if it actually works? (Yes I have seen this before).

If the answer to those questions is no, then it doesn't really matter how many branches you have-- developers will say that code is ready, working, and fit for production when it really isn't, and no number of branches will help you when that code goes up to production anyway.

Source Link
RibaldEddie
  • 3.3k
  • 1
  • 17
  • 17

I think the part of your question that is an anti-pattern is the use of a single shared master branch. However, if you were to include a develop branch in addition to the master branch and then use stashes to deal with your own context switches in the develop branch, that would not be an anti-pattern, and it very closely mirrors some of the workflow describe by organizations like Etsy and Facebook.

That having been said, @Greg Burghardt's answer above is a bit too favourable to the so-called git-flow or feature-branch work flow. I used to advocate for a similar strategy but after realizing that it adds unnecessary complexity and creates a false sense of security, I no longer do. It's also a holdover from the days of non-decentralized version control systems like subversion.

Firstly since Git is a decentralized version control system unlike subversion, a developer's local repository is essentially a giant branch of the code in and of itself. What an individual develop does locally doesn't and shouldn't have an impact on the other team members unless broken or buggy code is pushed up to any shared branches in a shared repository.

The rebase command, however, can damage the history of branch when there is a merge conflict in one of the replayed commits. From http://ryantablada.com/post/the-dangers-of-rebasing-a-branch

The rest of the rebase goes along smoothly, tests all seem to pass. A PR is made.

And then some more code is written that relies on the commentsForAllPosts property and everything is broken. But who do we go and ask for help? git blame shows that line of code has only been written by the server side engineer and he throws up his hands.

Now your front-end engineer is out on vacation, sick leave, or who knows. No one can figure out what that code should look like!

Rebase has killed the team's ability to look at the history to find what went wrong because any merge conflicts on the child branch are killed and the original code is lost forever.

If this same merge conflict came up and merge was used, the blame would show that that line of code had been touched in the merge process, the commit on the parent branch, and the commit on the child branch. Some toying around with the three permutations and you can get the original intent back into the code base and working without a ton of head scratching a finger pointing. And all you really had was another commit

Furthermore, a multiple branching model presupposes that no two branches could ever contain interdependent code changes. When that does inevitably occur, the developer now has to juggle yet more branches to work efficiently.

The fundamental anti-pattern that I see is not related to branches vs. stashes, but rather more about the kinds of problems that some very smart people have been talking about for a while now: do you have confidence in your code via the use of unit tests and a good architecture? Are you able to make incremental changes to your code such that your developers can reason about changes easily and understand what a change will do? Do your developers even run through new code once to see if it actually works? (Yes I have seen this before).

If the answer to those questions is no, then it doesn't really matter how many branches you have-- developers will say that code is ready, working, and fit for production when it really isn't, and no number of branches will help you when that code goes up to production anyway.