DEV Community


Discussion on: How to organize your git branches

asparallel profile image
AsParallel • Edited

Since no one answered and they're good questions:

  • I like these folders but what if you are not using gitflow?

Most guis will interpret the branch name as prefix/identity, gitflow doesn't have any impact on this, it just exploits it. You can choose your own adventure in that regard.

  • But I'm also worried about it conflicting with my current setup but maybe there is a way to mix?

The most natural way to mix would be to do a branch name with prefix/ticket-number, or prefix/#ticket-number if your system mandates the # to detect a ticket identity. You can also just put ticket numbers in the commit message body. In our case we require a ticket link to all associated issues, stories and epics so that's where we put the linkages. I've yet to see a system that won't correctly detect them there.

If you want to customize, see the end of this reply.

Note: regex: ʌ# is the matcher for comments on the git commit message, so be wary if using git-cli

  • Also how to you get gitflow on a current repo?
cd {local_repo_clone_dir} 
git checkout master
git branch -u origin/master
git flow init -d
  • Notes on gitflow, behavior

Gitflow as a tool is just an automator ( It creates a branch based on a convention, sets some configuration properties on the repository and the automates merging the finished code to the target branches.

Specifically regarding gitflow: Some products that support gitflow (ex: bitbucket) include githooks on the precommit event to check for naming convention. But that is the extent of the integration

The gitflow tool itself sets the following properties which can be used to configure how your branches are constructed.

Note: If you do pull requests as part of your process, you'll need to break out of gitflow at the PR stage as it's not supported.

git config gitflow.branch.master master
git config gitflow.branch.develop develop
git symbolic-ref HEAD refs/heads/master
git commit --allow-empty --quiet -m Initial commit
git branch --no-track develop master
git checkout -q develop
git config gitflow.prefix.feature feature/
git config gitflow.prefix.bugfix bugfix/
git config gitflow.prefix.release release/
git config gitflow.prefix.hotfix hotfix/
git config support/
git config gitflow.prefix.versiontag
git config gitflow.path.hooks <path>:/.git/hooks