How to Collaborate on GitHub

Create one repository, push your project, and add your teammates as collaborators so the whole team can work on the same code.

~4 min read updated Aug 1, 2026 Cheat Sheets
  • #github
  • #git
  • #collaboration
  • #teamwork
  • #setup

One team, one repository, everybody pushing to it. This is the setup for the Semester Project — follow it once at the start and you're done.

Only one person creates the repository. The rest of the team joins it as collaborators. Four repositories is not a team project, it's four solo projects that happen to have the same name.

Before You Start

Every member of the team needs their own GitHub account. No exceptions, no sharing an account.

Sign up at github.com with an email you'll still have access to at the end of the semester. Write down your username — your teammates need it to add you.

Create the Repository

Click New

From your GitHub dashboard, click the New button.

Name it and create it

Give it your project name, then click Create repository.

Use a name that says what the project is — cafe-order-system, not project or finalproject2.

Push Your Project

Open a terminal inside your project folder

Go to your project folder, right-click inside it, and choose Open in Terminal or Open Git Bash here.

Make sure the terminal opens inside the project folder, not one level above it. Push from the wrong folder and you'll upload the wrong files.

Follow the instructions GitHub gives you

Your empty repository page shows the exact commands to run. Use the block labelled "…or push an existing repository from the command line".

The commands look like this — copy them from your page, since the URL is different for every repository:

git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/USERNAME/REPO-NAME.git
git push -u origin main

Reload the page

Refresh your repository page. Your files should now be listed there.

If the page still shows the setup instructions, the push didn't work — read the error message in your terminal.

Add Your Teammates

Click Settings

Open the Settings tab of your repository.

Go to Collaborators, then Add people

In the left sidebar, choose Collaborators, then click Add people.

Type their username or email

Enter your teammate's GitHub username or email, then click Add to repository.

Repeat for every teammate.

Each teammate must accept the invitation before they can push. It arrives by email and also appears in their GitHub notifications.An unaccepted invitation looks exactly like a working setup right up until the moment someone tries to push and gets rejected.

Your Teammates Join

Once they've accepted, each teammate clones the repository onto their own machine:

git clone https://github.com/USERNAME/REPO-NAME.git

Use the owner's username in that URL — the repo lives in one place and everyone clones the same one.

That's it. They can now push to the repository.

Before Anyone Writes Code

Two things to do once, on every machine.

Set your Git identity

Use your own name and the email attached to your GitHub account:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
This is what makes your commits show up as yours. Your contribution grade is read straight off the repository's commit history, so get this right before your first commit — not after.

Add a .gitignore

Create a file called .gitignore in the project root:

.gitignore
node_modules/
.env
*.log
.DS_Store

Never commit node_modules/. It's thousands of files your teammates already have, and it makes the repository unusable.

The Daily Loop

Every time you sit down to work:

git pull

Work, then:

git add .
git commit -m "describe what you changed"
git push
git pullbefore you start, every single time. Four people editing the same repository will conflict eventually — pulling first turns "an evening lost to a merge" into "ten seconds of nothing happening."

When Something Goes Wrong

ProblemWhat to do
Permission denied / 403 on pushYou weren't added, or you never accepted the invitation
rejected — fetch firstSomeone pushed before you. Run git pull, fix any conflicts, push again
not a git repositoryYour terminal is in the wrong folder
Pushed the wrong filesAdd them to .gitignore, then git rm -r --cached <folder> and commit
I have no idea what I changedgit status and git diff

Full Command Reference

More Git commands than you'll need this semester: Git Cheat Sheet.

Related notes