diff options
Diffstat (limited to 'content/posts/2023-05-23-i-was-wrong-about-git-workflows.md')
| -rw-r--r-- | content/posts/2023-05-23-i-was-wrong-about-git-workflows.md | 95 |
1 files changed, 47 insertions, 48 deletions
diff --git a/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md b/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md index e1e45e8..16739de 100644 --- a/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md +++ b/content/posts/2023-05-23-i-was-wrong-about-git-workflows.md | |||
| @@ -7,66 +7,65 @@ type: posts | |||
| 7 | tags: [] | 7 | tags: [] |
| 8 | --- | 8 | --- |
| 9 | 9 | ||
| 10 | I have been using some approximation of [Git Flow](https://jeffkreeftmeijer.com/git-flow/) | 10 | I have been using some approximation of [Git |
| 11 | for years now and never really questioned it to be honest. When I create a repo | 11 | Flow](https://jeffkreeftmeijer.com/git-flow/) for years now and never really |
| 12 | I create develop branch and set it as default one and then merge to master | 12 | questioned it to be honest. When I create a repo I create develop branch and set |
| 13 | from there. Seems reasonable enough. | 13 | it as default one and then merge to master from there. Seems reasonable enough. |
| 14 | 14 | ||
| 15 | One thing that I have learned is that long living branches are the devil. | 15 | One thing that I have learned is that long living branches are the devil. They |
| 16 | They always end up making a huge mess when they need to be merged eventually | 16 | always end up making a huge mess when they need to be merged eventually into |
| 17 | into master. So by that reason, what is the develop branch if not the longest | 17 | master. So by that reason, what is the develop branch if not the longest living |
| 18 | living feature branch. And from my personal experience there was never a | 18 | feature branch. And from my personal experience there was never a situation |
| 19 | situation where I wasn’t sweating bullets when I had to merge develop back | 19 | where I wasn’t sweating bullets when I had to merge develop back to master. |
| 20 | to master. | ||
| 21 | 20 | ||
| 22 | This realisation started to give me pause. So why the hell am I doing this, | 21 | This realisation started to give me pause. So why the hell am I doing this, and |
| 23 | and is there a better way. Well the solution was always there. And it comes | 22 | is there a better way. Well the solution was always there. And it comes in a |
| 24 | in a form of [git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). | 23 | form of [git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). |
| 25 | 24 | ||
| 26 | So what are git tags? Git tags are references to specific points in a Git | 25 | So what are git tags? Git tags are references to specific points in a Git |
| 27 | repository's history. They are used to mark important milestones, such as | 26 | repository's history. They are used to mark important milestones, such as |
| 28 | releases or significant commits, making it easier to identify and access | 27 | releases or significant commits, making it easier to identify and access |
| 29 | specific versions of a project. | 28 | specific versions of a project. |
| 30 | 29 | ||
| 31 | Somehow we have all hijacked the meaning of the master branch that it has | 30 | Somehow we have all hijacked the meaning of the master branch that it has to be |
| 32 | to be the most releasable version of code. And this is also where the confusing | 31 | the most releasable version of code. And this is also where the confusing about |
| 33 | about versioning the software kicks in. Because master branch implicitly says | 32 | versioning the software kicks in. Because master branch implicitly says that we |
| 34 | that we are dealing with the rolling release type of a software. And by having | 33 | are dealing with the rolling release type of a software. And by having a develop |
| 35 | a develop branch we are hacking around this confusion. With a separation of | 34 | branch we are hacking around this confusion. With a separation of develop and |
| 36 | develop and master we lock functionalities into place and forcing a stable | 35 | master we lock functionalities into place and forcing a stable vs development |
| 37 | vs development version of the software. | 36 | version of the software. |
| 38 | 37 | ||
| 39 | But if that is true and the long living branches are the devil then why have | 38 | But if that is true and the long living branches are the devil then why have |
| 40 | develop at all. I think that most of this comes to how continuous integration | 39 | develop at all. I think that most of this comes to how continuous integration is |
| 41 | is being done. There usually is no granular access to tags and CD software | 40 | being done. There usually is no granular access to tags and CD software deploys |
| 42 | deploys what is present on a specific branch, may that be master for production | 41 | what is present on a specific branch, may that be master for production and |
| 43 | and develop for staging. This is a gross simplification and by having this | 42 | develop for staging. This is a gross simplification and by having this in place |
| 44 | in place we have completely removed tagging as a viable option to create a | 43 | we have completely removed tagging as a viable option to create a fix point in |
| 45 | fix point in software cycle that says, this is the production ready code. | 44 | software cycle that says, this is the production ready code. |
| 46 | 45 | ||
| 47 | One cool thing about tags are that you can checkout a specific tag. So they | 46 | One cool thing about tags are that you can checkout a specific tag. So they |
| 48 | behave very similarly as branches in that regard. And you don’t have the | 47 | behave very similarly as branches in that regard. And you don’t have the |
| 49 | overhead of having two mainstream branches. | 48 | overhead of having two mainstream branches. |
| 50 | 49 | ||
| 51 | So what is the solution? One approach is to use development workflow, where | 50 | So what is the solution? One approach is to use development workflow, where all |
| 52 | all changes are made on the smaller branches and continuously merged into | 51 | changes are made on the smaller branches and continuously merged into |
| 53 | master. Where the software is ready to be pushed to production you tag the | 52 | master. Where the software is ready to be pushed to production you tag the |
| 54 | master branch. This approach eliminates the need for long-lived branches and | 53 | master branch. This approach eliminates the need for long-lived branches and |
| 55 | simplifies the development process. It also encourages developers to make | 54 | simplifies the development process. It also encourages developers to make small, |
| 56 | small, incremental changes that can be tested and deployed quickly. However, | 55 | incremental changes that can be tested and deployed quickly. However, this |
| 57 | this approach may not be suitable for all projects or teams that heavily rely | 56 | approach may not be suitable for all projects or teams that heavily rely on |
| 58 | on automated deployment based on branch names only. | 57 | automated deployment based on branch names only. |
| 59 | 58 | ||
| 60 | This also requires that developers always keep production in mind. No more | 59 | This also requires that developers always keep production in mind. No more |
| 61 | living on an island of the develop branch. All your actions and code need to | 60 | living on an island of the develop branch. All your actions and code need to be |
| 62 | be ready to meet production standards on a much smaller timescale. | 61 | ready to meet production standards on a much smaller timescale. |
| 63 | 62 | ||
| 64 | I think that we have complicated the workflow in an honest attempt to make | 63 | I think that we have complicated the workflow in an honest attempt to make |
| 65 | things more streamlined but in the process of doing this, we have inadvertently | 64 | things more streamlined but in the process of doing this, we have inadvertently |
| 66 | made our lives much more complicated. | 65 | made our lives much more complicated. |
| 67 | 66 | ||
| 68 | In conclusion, it's important to re-evaluate our workflows from time to time | 67 | In conclusion, it's important to re-evaluate our workflows from time to time to |
| 69 | to see if they still make sense and if there are better alternatives available. | 68 | see if they still make sense and if there are better alternatives available. |
| 70 | Long-living branches can be problematic, and using tags to mark important | 69 | Long-living branches can be problematic, and using tags to mark important |
| 71 | milestones can simplify the development process. | 70 | milestones can simplify the development process. |
| 72 | 71 | ||
