Home/Blog/Coding & Data
Coding & Data · 11 min read

How to use Git and GitHub for a team project, step by step

The short answer

To use Git and GitHub as a team, put the project in one repository, turn on two-factor authentication, and protect main. Work on short-lived branches, one per issue, and merge through small pull requests that a teammate reviews and tests check. Resolve conflicts by agreement, keep secrets out with .gitignore, and use git revert for pushed mistakes.

Want the tools, not just the method? The The Git and GitHub for Students and Teams Kit kit turns this guide into ready-to-use templates, spreadsheets and printables, with an instant download.

Key takeaways
  • Nobody works on main: every change goes through a branch and a pull request.
  • Small pull requests get faster, better reviews; set a size limit, such as 300 changed lines.
  • A merge conflict is Git refusing to guess; the owner of the rule decides.
  • A leaked secret is rotated first, then removed from the code.
  • Before any undo, ask: is it committed, and is it pushed?
  • Students: your institution's integrity rules come first, including for AI tools.

What are the steps to set up Git and GitHub for a team?

Most team problems with Git are set-up problems in disguise: commits from the wrong identity, a password that does not work, a repository with no rules. Do these steps once, together, before anyone writes more code. Book an hour, sit in the same room or on one call, and have each person share their screen while they run the commands.

The point of the last step is proof. A set-up is only finished when every person has pushed a branch, opened a pull request, had it reviewed and seen it merged. Anything that fails in that hour would have failed at 11 p.m. before a deadline, so it is the cheapest hour of the whole project.

  • 1. Install Git and set your name, email and default branch once with git config --global (init.defaultBranch main needs Git 2.28 or newer).
  • 2. Turn on two-factor authentication on every GitHub account; GitHub requires it for people who contribute code.
  • 3. Authenticate with an SSH key or HTTPS through a credential manager; account passwords no longer work for Git.
  • 4. Create one repository with a README, a starter .gitignore and a licence or ownership note; invite the team and your instructor or sponsor.
  • 5. Protect main: require a pull request, one approval and passing tests, and block force pushes.
  • 6. Agree a one-page working agreement covering branch names, pull request size, review times, tests, secrets and AI use, then have each person push a one-line change through a pull request to prove their set-up works.

How do you keep a team's commit history readable?

A commit should hold one logical change, small enough to understand and, if needed, undo on its own. Before committing, read your own change with git diff --staged. If you fixed two unrelated things, stage them separately with git add -p and make two commits.

Messages follow a long-standing convention from the Git project: a summary line of about 50 characters in the imperative mood ('Add renewal rule', not 'Added renewal rule'), a blank line, and a short body that explains why. Code shows what changed; only the author knows why. Researchers who examined almost 1,600 commit messages from five active open-source projects judged that about 44% could be improved, so a shared template is worth setting up on day one.

Commit counts per person are a useful early warning (someone silent for two weeks may be stuck) but a poor measure of contribution. Tests, reviews and documentation protect everyone and rarely produce many commits.

How should a team use branches?

A branch is a movable name for a line of work, and creating one is instant. Give every issue its own branch, named after the issue (for example 12-search-by-author), and keep it short-lived: one to three days. When it is merged, delete it.

When you merge, Git either fast-forwards (main had not moved, so the name simply moves forward) or makes a three-way merge with a merge commit that has two parents. If both sides changed the same lines, it stops with a conflict. Long-lived branches drift away from main and turn small conflicts into big ones.

Merge or rebase? Rebasing gives a tidy history by replaying your commits, but it rewrites them. The Git book's rule is not to rebase commits that others may have based work on. For a student team, merging main into your branch, and rebasing only work you have never pushed, is the safe default.

Two daily habits prevent most branch trouble. Pull or fetch before you start work, so you begin from the team's latest code, and push at least once a day while a branch is open, so your work is backed up and visible. If a push is rejected because a teammate pushed first, pull, check what arrived and push again; never answer a rejected push with --force.

Why do small pull requests matter so much?

A pull request proposes merging a branch so teammates can discuss, review and test it first. Reviewers can read a small change properly; they skim a big one. In Google's study of 9 million reviewed changes, the median change modified 24 lines, and small changes got first feedback in a median of under an hour, against about five hours for very large ones.

Here is a worked example from a four-person student team (a composite, with numbers from the kit's workbook). In weeks 4 to 6 their median pull request changed 491 lines and waited 29.1 hours for a first review; 7 of 11 waited longer than their 24-hour target. In week 7 they set a 300-line limit and switched on branch rules. In weeks 7 to 15 the median was 138 lines and 9.3 hours, with none over target. Several things changed at once, so treat it as a change worth copying, not proof of cause.

MeasureWeeks 4-6 (11 PRs)Weeks 7-15 (37 PRs)
Median changed lines491138
Median hours to first review29.19.3
PRs waiting over 24 hours70
PRs over the 300-line limitmost (no limit yet)2

How do you review a pull request well?

Reviews are where a team learns from each other, so treat them as part of the work, not a favour. Give reviews a time slot each day and agree a response target, such as 24 hours on weekdays. Start by saying what the change does in one sentence; if you cannot, ask the author. Run or read the How to test steps. Check names and structure, whether tests cover the new rule, and whether anything looks like a secret or personal data. For interface changes, check labels, contrast and keyboard use.

Then decide: approve, approve with optional suggestions, request changes saying exactly what and why, or ask to split. Comment on the code, not the person. If you use the code review skill at work, an assessment such as AssessAll's Code Review Assessment for Software Engineering Teams can show where your judgement is strong and where to practise.

How do you resolve a merge conflict without losing work?

Conflicts are normal in team work and not a sign that anyone did something wrong. A conflict is Git refusing to guess when both sides changed the same lines. Inside the file, everything between <<<<<<< HEAD and ======= is your side, and everything down to >>>>>>> is the incoming side. Research on open-source projects found collaboration conflicts to be frequent and persistent, which is why finding them early, in small merges, matters.

  • Stop and read both sides; git status lists the conflicted files.
  • Ask who owns the rule; that person decides, not whoever is typing.
  • Write the agreed result, which may combine both sides, and delete every marker line.
  • Run the tests, then git add the file and git commit with a message that says how you resolved it.
  • If you get lost, git merge --abort returns you to before the merge.
Measure where you are

Reading helps; measuring tells you what to work on. These AI-graded assessments on AssessAll pair with this topic:

What should you do if you push a password or API key?

Researchers who scanned billions of files found secret leakage affecting over 100,000 public GitHub repositories, with thousands of new secrets leaked every day. Deleting the file is not enough, because the secret stays in history and in every clone.

Prevention is simple. Keep real values in a .env file that .gitignore excludes, commit a .env.example with placeholder values so teammates know which settings exist, and check .gitignore before the first commit, not after. Remember that ignore rules do not affect files already tracked; a committed file must be untracked with git rm --cached.

If it happens anyway, rotate first: revoke the secret where it was issued and create a new one. Then store the new value in an ignored .env file, commit .gitignore and a placeholder .env.example, tell your instructor or manager, check the provider's logs and record what happened. GitHub's secret scanning covers the full history of public repositories for free, and push protection blocks recognised secrets before they land; GitHub itself notes that scrubbing history is often unnecessary once a credential is revoked.

How do you undo a mistake in Git safely?

Ask two questions: is it committed, and has it been pushed? Uncommitted edits can be discarded with git restore (which really does delete them) or unstaged with git restore --staged. A commit that is not pushed can be amended or undone with git reset --soft, which keeps your work staged. A pushed commit should be reversed with git revert, which adds a new commit and keeps everyone's history intact.

Commit early and often while you work on a branch: anything committed can almost always be recovered, while edits that were never committed may be gone for good. Avoid git reset --hard and git push --force on anything shared: the first destroys uncommitted work and the second can delete teammates' commits from the remote. If you lose a commit or a branch, git reflog lists where HEAD has been, by default for 90 days.

Common mistakes teams make with Git and GitHub

  • Working on main, so every half-finished change breaks the app for everyone.
  • Giant 'everything I did on Sunday' commits with messages like 'stuff'.
  • Answering a rejected push with --force instead of pulling first.
  • Rubber-stamp approvals of pull requests too big to read.
  • Adding .env to .gitignore after it was committed, and thinking it is now untracked.
  • Letting an AI assistant decide a conflict nobody can then explain.

How should students use AI assistants with Git?

Your course rules come first; many university codes treat unauthorised aids as cheating and letting others copy your work as an infraction. Where AI is allowed, use it to explain commands, errors and each side of a conflict, and decide yourselves. Never paste secrets or personal data, and declare AI use where required.

The evidence on speed is mixed: a controlled one-task experiment found developers with an AI pair programmer finished 55.8% faster, while a 2025 randomised trial with experienced open-source developers found they took 19% longer with AI tools on real tasks in their own projects. Measure your own work. To turn practice into a habit, tie each session to a cue; Jobulary's guide to if-then plans explains how. The Git and GitHub for Students and Teams Kit includes a 30-day plan and 12 exercises that build real repositories.

Bodhih Pro Kit

Practise every step on real repositories

The Git and GitHub for Students and Teams Kit gives you 12 exercises that run on your own computer, the team templates and a 30-day plan. Start with the 15-minute quick start.

Common questions

Questions people ask next

Is Git the same as GitHub?

No. Git is the version control tool on your computer; GitHub is a hosting service built around Git that adds pull requests, reviews, issues, Actions and Pages.

Should a student project repository be public or private?

Private during the course unless your instructor says otherwise, because public graded work can let others copy it. Ask before making it public afterwards for a portfolio, and never include anyone's personal data.

What is a good pull request size?

Small enough to review properly in one sitting. Many teams set a limit, such as 300 changed lines, and split anything bigger. Measure your own review times and adjust.

Does .gitignore remove files that were already committed?

No. Ignore rules only affect untracked files. Stop tracking a committed file with git rm --cached, then commit.

What is the difference between git revert and git reset?

Revert adds a new commit that undoes an earlier one and keeps history, so it is safe for pushed work. Reset moves your branch back and can discard work, so use it only on commits you have not pushed.

Do I need GitHub Actions for a student project?

It helps: a workflow that runs your tests on every pull request catches broken changes before they reach main. Actions is free on standard runners for public repositories; private repositories get a monthly allowance by plan.

What is trunk-based development?

A way of working where everyone merges small changes into the main branch at least daily through short-lived branches. DORA's research links it with higher delivery performance, as an association rather than proof.