Search code examples
gitbranchgit-branchbranching-and-merginggit-flow

Management of remote branches in Git with GitFlow


I have a question about the management of branches in GIT. I'm following GitFlow. I know its operation in terms of branch structure, no problem there, but I don't know how to manage the synchronization with remote correctly. For example:

  • I make a branch hotfix-error_XXXX from master

If it's a little change and I will solve it immediately, should I synchronize this branch with remote or is't not necessary? that is, do I solve the problem and do merge in local master and finally delete the hotfix branch without going through remote?

Another question is, should these remote branches be deleted in addition to the local branches? That is, those that have to do with hotfix or features.

Thank you!


Solution

  • should I synchronize this branch with remote or is't not necessary?

    No. in GitFlow, each GitFlow's branch have a specific role.

    • master: your main branch, it's where all you release version is supposed to be, and it's what users will see.

    • develop: kind of 'clone' of master, we pass by an intermediate branch like develop instead of master because we can implement each feature and fuse them on develop before make our release on master.

    • feature: you should create one feature branch for each feature you want to implement, it's allow you and your coworker to work on different feature without side effect.

    • bugfix: start it when you have a bug to solve, to correct it without alter your coworker's work, like that one of you can focus to the bug's resolution and the rest can continue.

    • hotFix: the part who interest you. a hotfix branch have to correct an IMPORTANT and URGENT problem on purpose, it's why it start from master branch, because an important problem who need to be correct as quickly as possible is usually on the master branch, if you haven't make your release (so your version is only on develop and not master), start a bugfix branch should be sufficient. The hotfix is to correct an important thing urgently on the master branch.

    should these remote branches be deleted in addition to the local branches?

    Yes. if you have successfully finished with these branch and merged into master, and if you have not planned to reuse them, yes delete them. But it's depend on people, some people prefer to keep them to have a really 'complete' history, and other prefer to have a 'clean' repository without unused branch (which will still be useless).