Search code examples
gitgitlabatlassian-sourcetreegit-flow

Use Gitflow on two different developers' computer


I use gitflow on my PC to develop my code. The repository is hosted on a self hosted instance of gitlab. The client I'm using is Sourcetree.

My process to create a new project is to create the main branch of the project on gitlab using its web interface. Then I clone the main branch on my PC and I use the Sourcetree button to initialize gitflow: at the end I have two local branches named main and develop and if I use the tool in Sourcetree to start a new feature it creates the $FEATURE_NAME branch where I can work until I finish the feature and I can use again the Sourcetree tool to end the feature and merge the branch on develop.

At this point I start working on the develop branch and I push the branch itself on gitlab to enable sharing it.

Now I'd like to work with gitflow and to take advantage of the sourcetree integration on another PC, but I don't really understand how should I proceed: I can clone the project from gitlab, but I have to choose which branch I want.

My first tought was to clone the main branch and the develop branch, but then I would miss the Sourcetree gitflow integration: I tried and I don't have the gitflow intialized so I cannot start a new feature from Sourcetree.

What is the correct procedure I should follow?


Solution

  • As per @blacktide comment, the solution is to point the repository on GitLab first, then executing git flow initialization won't recreate the branch. Git will recognize that the develop branch is available on origin and will check out a new local copy of that branch.