How To Collaborate On A Github Repository

·

3 min read

In this article, I'll be giving you tips on how to do the following;

let's do this!

Create A Repository

I'll be showing you how to do it with your PC. Doing it on your phone would be similar.

  1. Go to github.com My github homepage

    you would need to login if you haven't already

  2. Head over to your repositories Navigating to my repositories
  3. Click on New to create a new repository Creating a new repository
  4. Provide a name and a description for your project then click on Create repository below. Finishing up

Add A Collaborator

I'll be showing you how to do it with your PC. Doing it on your phone would be similar.

  1. Go to github.com My github homepage

    you would need to login if you haven't already

  2. Head over to your repositories Navigating to my repositories
  3. Find the repository you want add a collaborator to. When you find it, click on it.

    Alternatively, you can go to the repository using a link. If your github username is flyingfish and the repository name is foobar, the the link would be https://github.com/flyingfish/foobar.

  4. Navigate to the repository settings Navigating to my repository settings
  5. Find Collaborators and click on it. It's using on the left part of the screen. My repository settings

    You might be asked to authenticate. Authenticate using your github mobile (if you have the mobile app) or password.

  6. You can now search for your partner using their username. This would give them access to your repository

Clone Repository

Now this step involves having a PAT or Personal Access Token. You can find out out to get yours [here].(docs.github.com/en/authentication/keeping-y..)

To clone the repo, both you and your partner need to include your PAT in the url. So lets say the following information was yours;

username = flyingfish
PAT = ghp_1234567890

And your partner's information looked like this;

username = julienbarbier
PAT = ghp_101010110101

Then the name of the repository is foobar. If you want to clone it, you'll type;

git clone 'https://ghp_1234567890@github.com/flyingfish/foobar.git'

For your partner, they'll clone it like this;

git clone 'https://ghp_101010110101@github.com/flyingfish/foobar.git'

Notice that your partner still uses your repo (flyingfish/foobar) to clone .

Collaboration Is Key

To collaborate efficiently without making a mess or creating conflicts, you and your partner need to work on separate branches. So, create a new branch and have your parner do the same; none of you should work directly on the default branch.

I'll be making a few assumptions

1.Your branch name is the same as your username

  1. Your default branch is main (sometimes, it could be master)

Your workflow would now look like this

  • checkout to your branch. This step should only be done once - immediately after cloning.
git checkout flyingfish
  • get all changes locally
git pull origin main
  • make changes and make commits, then;
  • make all changes reflect on github
git push -u origin flyingfish
  • repeat...

This would be all you need to get the ball rolling. I hope this article would be useful to you as we keep doing #hardthings