Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top