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.
- Pull any new changes into the main branch
- git checkout main
- git pull
- Create a new branch. remember the -b and change my-feature to be a simple name for what you’re doing
- git checkout -b my-feature
- Do you work. Make sure it works
- Commit your changes
- It may be easier to do this through the interface. But you can also use the git command in the terminal
- git commit -m “the message you want”
- change back to the main branch
- git checkout main
- Pull again in case anyone has made changes to main
- git pull
- Merge the branch into main. change my-feature to whatever your branch was named
- git merge my-feature
- Push your changes up to GitHub
- git push
- You’re done. Optionally you can delete your branch now that it’s merged.
- git branch -d my-feature
- 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)
32 comments