Collaborate on GitHub

Here are some of the basics for collaborating on GitHub.

Use a Single, Shared Repository

One of the people in the group will create the repository that everyone will use. After the Repository is created then invite the other members to collaborate on that.

DO NOT FORK THE REPOSITORY. We did that with mine and the LinkedIn learning so you had your own copy. In this case you want everyone to be on the same repository so don’t fork it.

Here is a video showing the process of inviting collaborators and accepting the invite.

Work on Branches

Once everyone is on the same repository, then when you do to do work, create a branch. when you’re done working then you commit changes and merge the branch.

Here is an outline of the basic process. Code examples are what you type in the terminal.

  1. Pull any new changes into the main branch
    1. git checkout main
    2. git pull
  2. Create a new branch. remember the -b and change my-feature to be a simple name for what you’re doing
    1. git checkout -b my-feature
  3. Do you work. Make sure it works
  4. Commit your changes
    1. It may be easier to do this through the interface. But you can also use the git command in the terminal
    2. git commit -m “the message you want”
  5. change back to the main branch
    1. git checkout main
  6. Pull again in case anyone has made changes to main
    1. git pull
  7. Merge the branch into main. change my-feature to whatever your branch was named
    1. git merge my-feature
  8. Push your changes up to GitHub
    1. git push
  9. You’re done. Optionally you can delete your branch now that it’s merged.
    1. git branch -d my-feature
    2. if you get an error that it hasn’t been pushed or merged, make sure you actually merged it into main.

Here is a video that goes over that (Except for deleting)

1 comment

Leave a comment