Skip to content
Start » git » Simple Git Workflow

Simple Git Workflow

In this article I present a proposal for a simple workflow using the source code version market standard, git workflow.

For an efficient management of a software development project, in addition to the elementary use of a versioning, it is important to define an organization standard for the team.

simple git workflow

The following image presents a diagram that summarizes the regular work, in a simplified way, in a development project with code versioning using Git:

Git Workflow simples

The following sequence describes the step by step for this workflow, considering a path without the occurrence exceptions in the progress of the development of a software project:

  • Repository creation
$ git init
  • Initial commit to branch master
$ git add . $ git commit -m 'Initial commit'
  • protect the branch master so that it is not possible to push directly to it.
  • branch creation dev to be used by the development
$ git checkout -b dev
  • Make commits to the branch dev
$ git add . $ git commit -m 'My new functionality' # push to central repository whenever needed $ git push origin dev
  • When the time comes to test for publishing the application in production, create the branch test:
    • If the branch does not yet exist, create it from dev:
$ git checkout -b test
  • merge dev in test, send to the central repository and perform the deployment on the test server
$ git checkout test $ git merge dev $ git push origin test
  • If all tests pass, merge test in master, create version tag, then publish to production
$ git checkout master $ git merge test $ git tag 'v.0.1.0' $ git push origin master $ git push --tags
  • Continue development in dev
$ git checkout dev
  • New stability point for production publishing, again merge dev in test
$ git checkout test $ git merge dev
  • If any error/failure is found in the test, correct it in dev
  • After corrections, new merge of dev in testprevious commands
  • After all tests are accepted, merge from test in master, version tag, publish to production – production and master publish commands explained above
  • Continue the described workflow

In this way, we consider that the version in production will always be the same as the last tag of the branch master. The latest version in the staging environment will always be the last entry (HEAD) in the branch test.

While development continues working on the branch dev with the new features to be implemented.

Simple Git workflow and bug fixes

Note that it is still possible to create branches from the master if any errors are identified in the production version, while the development of new features has advanced, the following diagram exemplifies this context:

Git workflow simples com bugix

So when a bugfix is needed in the version running in production:

  • A new branch is started to fix the bug, in this example the branch is called bugfix-0.1.0
  • This new branch must be started from master because the branch dev already has changes that have not yet been tested
$ git checkout master $ git checkout -b bugfix-0.1.0
  • Make the necessary commits for the correction/change in the branch bugfix-0.1.0
  • Test yourself, whether or not you can send it to the branch test , in this example we consider a direct test of the bugfix
  • The merge of bugfix for master, and also for dev, in order not to miss the fix in future versions that are in development
$ git add . $ git commit -m 'Fixes implemented' # tests performed $ git checkout master $ git merge bugfix-0.1.0 $ git push origin master $ git checkout dev $ git merge bugfix-0.1.0 $ git push origin dev
  • At this point it is possible to exclude the branch of bugfix if desired, as the changes will have been merged into the branch dev

Final considerations

This is a very simple workflow, but it serves projects with small teams or projects where the development of features and deliveries occurs in a “linear” or sequential way.

I would say it works well, especially for solo developers.

keep up to date

Don't forget to follow me on twitter and sign the Mazer.dev channel on Youtube to receive updates on new articles, video lessons and free courses in software development and engineering.

More about Git

How to resolve “error: src refspec main does not match any” in Git
The error message: "error: src refspec main does not match any" happens for some routinely common causes, particularly when starting a new project repository. A second message line with the text: "error: …
Free e-books on programming and computing in general
Looking for free e-books on programming, software development, and other areas of computing? This list includes these topics as well as books on software engineering and other subjects. The pandemic period has exploded…
Git quick tip: git checkout specific files from another branch
The git checkout command can be used to update specific files or directories in your working tree with those in another branch, without having to merge the entire branch. This can be …
Creating the README of your profile on Github
Customize the README of your profile on Github, make your programmer business card "your face" and increase the visibility and clarity of your technical position in the area of software development. …
semantic git commits
Semantic commits in the use of Git and other VCS (code versioning systems) are the best way to document implementation execution, as they give context to change management. Write commit messages…
How to fix slow GIT with SSH on Github, Gitlab or Bitbucket
To fix slow push and pull GIT commands, when we are using ssh keys in Github, Gitlab and Bitbucket repositories services, it is necessary to change the IP version configuration used. I like …

Leave a Reply

Your email address will not be published.

en_USEnglish
%d bloggers like this: