Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it make sense to create a branch for every developer?

Tags:

I've used Git only for sole projects. Now I want to continue working on a project with two other developers.

Would it cause problems if one developer wants to commit changes but another commit was created by another developer? Therefore would it make sense to create one branch for each of us?

like image 990
danijar Avatar asked Jun 25 '13 17:06

danijar


2 Answers

Git, like most version control systems, is eminently well suited for use by multiple developers. Indeed, it is one of the main points of a version control system.

There is no need to create a branch per user. I would even go so far as to say that it would be counterproductive. If you are working on the same feature, you will probably want to get each other's changes, by pulling and merging. Creating branches per user is redundant and will complicate things unnecessarily.

The commit situation you describe is not problematic. If another user has created a new commit on the same branch as you, you will be stopped if you try to push. Instead you will first have to pull down the other user's commit and merge (or rebase) your work with those changes. This is the standard behavior of git pull.

Normal practice is to create branches based mainly on features. If you want guidance on branching, this is a popular strategy.

like image 153
Klas Mellbourn Avatar answered Oct 24 '22 23:10

Klas Mellbourn


We used to do that in a place where I worked. Each of us had at least one personal branch - I actually created a branch for every task I had to do.

When we were done, we would do pull requests to the main branch. If someone has merged into the main branch code that conflicts with your changes, you have to do the conflict resolution just as you would with any other source control platform (like Tortoise, Mercurial etc.), but it's no big deal if your devs know what they're doing.

IMO this is the best way to conduct development in a team. You can always test in your own personal environment, quickly swicthing code from each branch as needed. The pull request system also makes peer review so much simpler, since everybody can collaborate and write comments on the relevant lines directly in the github diff pages.

like image 42
Geeky Guy Avatar answered Oct 24 '22 21:10

Geeky Guy