Multiple people commiting to the same branch on Git

Issue

I’ve been using git alone for a long time, but now need to include many artists in a collaborative project.

These people are fairly new to git, so I’ve written the following (likely incorrect) instructions for checking out another person’s branch:

  1. Open the Git GUI and open our repository
  2. Remote>Fetch From>origin
  3. Branch>Checkout>(the branch you want)
  4. Stage, commit, and push as normal

Attempting to commit after using these instructions results in a warning about committing to a detached head. If they try to push these commits, nothing seems to happen.

So what is the correct way to have multiple people on the same branch? I’m hoping it’s simpler than what I wrote above, people are already screwing things up.

Solution

Ask them to create first fork your repository. It’s then easier for them to push to their own remotes and file a pull request to your remote. Once they have forked, they can clone it to their local and then create a new branch like so:

git checkout -b feature_branch

This will create the new branch straight from where your remote master branch was, otherwise it’s better do git checkout -b feature_branch origin/master.

Ask them to then push this branch to their remote. If their remote name is own_remote, pushing this feature branch will create a new branch own_remote/feature_branch. Since they have cloned the repository from their remote, they can push to it (in that case that remote would be origin by default). If they want to push the feature_branch to their remote, they can do it like so:

git push origin feature_branch

Then if they think their changes are worthwhile and need to go it the main development branch (which is yours), they can send you a pull request.

Answered By – gravetii

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published