Gitflow Workflow — 101

Gitflow Workflow — 101

Gitflow Workflow — 101

Gitflow is a collection of command line git extensions to automate a branching strategy introduced by a 2010 blog post entitled ‘A successful Git branching model’ by Vincent Driessen , This provides a robust framework for managing larger projects.

- Install Gitflow:

you can install gitflow easily on macOS using “Homebrew” by running : “brew install git-flow” and you can follow download instructions here.

- Init gitflow 🏁:

to initialize gitflow in your working directory you can simply navigate to your working directory using “cd /workingDirectory” , then you should run the following to initialize gitflow “git flow init -d”

as you can see it have created two branches “master” & “develop”as you can see it have created two branches “master” & “develop”

master branch will be used for production releases , and develop will be used for developing new releases.

- Develop new feature 🛠:

then we’re going to develop a new feature , merge it to develop branch , and delete it , all of this is so easy using “git flow feature start feature-name” command as the following :

as you can see after running feature start command it switching you automatically to the new feature branch based on develop branch and tells you to start committing on your featureas you can see after running feature start command it switching you automatically to the new feature branch based on develop branch and tells you to start committing on your feature

now you can easily commit a change in your files as the following for example :

now we have successfully commit our changes.now we have successfully commit our changes.

it’s time to finish our feature 💃🏻 run “git flow feature finish feature-name” command as the following :

now our feature branch has beed merged into develop branch , locally deleted , and we are switched to develop branch.now our feature branch has beed merged into develop branch , locally deleted , and we are switched to develop branch.

- Create new release 🚦 :

while you’re working on your software you may need to update some files on production to support new release , so release branch will be merged into both develop and master after we finish working on it . so let’s start and deliver a new release run “ git flow release start v1.0” command :

a new release branch has been created successfully and you can start committing on it.a new release branch has been created successfully and you can start committing on it.

after modifying and updating our files we add them and commit our changes :

now it’s time to complete the release run the following command to finish our release “git flow release finish -m ‘v1.0’ v1.0” .

our release branch has been merged into both master and develop and has been locally deleted.our release branch has been merged into both master and develop and has been locally deleted.

- Hotfix ⚠️🔥 :

Hotfix is used to fix issues with releases , Hotfix branch is created from master branch to fix the last release if it contains any issues :

new branch is created for hotfix based on master branch , and switched to it.new branch is created for hotfix based on master branch , and switched to it.

now do your fixing process and commit your work then finish the hotfix by running “git flow hotfix finish -m ‘v1.0.1’ v1.0.1”

hotfix branch has been merged into master and develop , and has been locally deletedhotfix branch has been merged into master and develop , and has been locally deleted

- Note 📝 :

you can share your work on “feature , release , hotfix”to other developers by running “ git flow release publish v1.0” just repleace release with feature or hotfix and your work will be pushed into your remote.

- Conclusion 💡 :

  • git init creates two branches for you “master” as production branch , “develop ” as development branch.

  • release and feature branches is created from develop branch.

  • when feature is completed it’s merged into develop branch.

  • when release is completed it’s merged into both develop and master.

  • if there an issue in release a hotfix branch is created from master.

  • when hotfix is complete is merged into both develop and master.

  • use publish to share your work on the remote.

That’s it hopefully you got it and it was simple and clear for you, if you found this article helpful please leave some claps and share it so everyone can benefit from it too ❤️

Greetings to SwiftCairo & LintSchool ❤️🇪🇬