Search code examples
gitversion-controlgithubcollaboration

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


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?


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.