In this article, I'll be giving you tips on how to do the following;
- create a repository on github
- add a collaborator to your repository
- clone repository (for both you and your partner)
- work collaboratively on the same repository
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.
- Go to github.com
you would need to login if you haven't already
- Head over to your repositories
- Click on
New
to create a new repository - Provide a name and a description for your project then click on
Create repository
below.
Add A Collaborator
I'll be showing you how to do it with your PC. Doing it on your phone would be similar.
- Go to github.com
you would need to login if you haven't already
- Head over to your repositories
- 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 isfoobar
, the the link would behttps://github.com/flyingfish/foobar
. - Navigate to the repository settings
- Find
Collaborators
and click on it. It's using on the left part of the screen.You might be asked to authenticate. Authenticate using your github mobile (if you have the mobile app) or password.
- 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
- Your default branch is
main
(sometimes, it could bemaster
)
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