Collaborating with Git for group projects
Companion to M02 · pull-first habits, shared repositories, conflict resolution
What this page is for
In M02 you met Git and GitHub as a solo workflow: you commit your changes on your laptop, push them to GitHub for backup, and rarely have to think about anyone else’s edits. That changes when you start your group project. Suddenly two or three people are touching the same .qmd files, and the question of whose changes are where becomes real. This page is meant to make that transition feel manageable.
Read it before your first group-project work session. Then come back to the Daily checklist at the bottom whenever you sit down to work with teammates.
What changes when you go from solo to collaborative
When you work alone in a Git repository, the timeline is simple: every commit you make extends a single straight line of history. Push when you want a backup, pull when you’ve worked on another machine, and there’s never any question about which version is current.
Group work breaks that simplicity. Each teammate’s laptop carries its own copy of the repository, each is making commits, and the shared GitHub repository is the place those parallel timelines get reconciled. The same file can be edited by two people at the same time, and the order in which everyone pushes their changes matters. The two skills that hold this together are:
- Pulling before you start working — so you’re editing the most recent version of every file, not a stale copy from yesterday.
- Coordinating who edits what — so you and your teammates rarely touch the same line of the same file at the same time, and conflicts stay rare and small.
The rest of this page unpacks both.
The pull-first habit
The single most important collaborative-Git habit is this: pull before you start working. Every single time.
Why this matters: while you were away from the project — for a day, an hour, even fifteen minutes — your teammates may have committed and pushed changes. If you open RStudio and start editing without pulling first, you’re editing a stale copy of the project. When you eventually push your work, Git has to figure out how to reconcile your edits with the newer history on GitHub — and if you happened to edit the same lines a teammate already edited, you’ve just created a conflict that would not have existed if you’d pulled first.
The right rhythm:
- Open your laptop. Don’t open RStudio yet.
- Open GitHub Desktop first. Click the repository in the left sidebar.
- Click Fetch origin (top of the window). This asks GitHub “is there anything new?” — without pulling it yet.
- If GitHub Desktop says “Pull origin” (the button label changes), click it. This downloads any changes your teammates pushed since you last looked.
- Now switch to RStudio and start working.
Most days this pull-first check takes about ten seconds. (Days when GitHub Desktop pulls down a teammate’s work take a little longer; days with a conflict take a few minutes to resolve.) It is one of the simplest habits that prevents bigger headaches later.
The pull-first habit · phrase it as a rule
“Open GitHub Desktop before RStudio. Pull before you type.”
Say it out loud the first few sessions. After a week, it’s muscle memory.
Commit small, push often
Solo Git can hide sloppy commit habits. Collaborative Git makes them visible.
- Commit when you’ve finished one coherent thing. A polished figure, a cleaned-up wrangling chunk, a section of prose — anything that “belongs together.” A useful test: if you had to write a commit message in seven words or fewer, could you? If yes, commit. If not, your changes are doing too much at once and should be split into two commits.
- Push at the end of every work session (and ideally at lunch, at coffee, whenever you take a break). Your teammates can’t see — or build on — work that’s sitting on your laptop. Pushing is how you make your contribution available to the team.
- Don’t sit on hours of uncommitted work. Uncommitted edits are not just hidden from teammates; they’re not backed up. A laptop dropped in the parking lot at 4:30 PM takes uncommitted work with it.
The combined rhythm: pull → edit → commit → push. Repeat several times a session, not once at the end.
Coordinating who works on what
The simplest way to avoid conflicts is to make sure two people aren’t editing the same file at the same time. For PSY 652 group projects (typically 2–3 students working on one Quarto notebook), three strategies work well together:
Divide files by responsibility. Project 1, for example, has a single
p1_data_brief.qmdnotebook with sections for the question, measurement, the analytic sample, Table 1, the figures, and what the findings mean. Assign each section a primary editor — the person who makes the keystrokes there, which is what prevents most conflicts.Primary editor does not mean sole expert. At least one teammate should read and review every section, and by the presentation everyone needs to understand the complete analysis — any of you can be asked about any part of it. Divide the typing, not the understanding.
Communicate before opening a file. A quick Slack message — “I’m going to edit the wrangling section for the next hour” — is enough. The teammate then waits, or works on a different section. Coordination costs nothing.
Make a small commit and push the moment you finish a focused chunk. The longer your uncommitted edits sit, the more likely a teammate has already changed the same file. Frequent commits and pushes keep everyone’s view of the project in sync.
For a 2–3 person team working in a single notebook, you do not need to learn Git branches (a way to maintain parallel timelines and merge them deliberately). The coordination strategies above are simpler and more than enough.
This is a deliberately simplified course workflow: everyone commits directly to the main branch — but only after pulling first and coordinating who’s editing what. Most professional software teams use branches and pull requests (a structured way to propose changes and have them reviewed before merging into main) for larger collaborations; if you take a more advanced course or contribute to an open-source project later, those are the next things to learn.
When conflicts happen anyway
A conflict happens when Git tries to merge two sets of changes and cannot safely decide what the final file should look like. The most common case is when two people edited the same line of the same file. Conflicts can also happen when one person edited a file and another person deleted or renamed it.
This is normal. Conflicts are not a sign you did anything wrong — they usually mean two people edited overlapping parts of the project before those edits were brought together. Resolving them is a five-minute task once you know the shape.
What a conflict looks like in GitHub Desktop
When you click Pull origin and GitHub Desktop discovers a conflict, it stops and tells you: “There are conflicting files in your repository. You can attempt to resolve them in your external editor.”
If you open the conflicting file in RStudio, you’ll see something like this in the middle of it:
The mean SBP in this sample was
<<<<<<< HEAD
131.4 mmHg, slightly above the clinical threshold.
=======
133.2 mmHg, indicating elevated cardiovascular risk.
>>>>>>> origin/main
The lines between <<<<<<< HEAD and ======= are the version currently on your machine — in a pull-from-main workflow like this one, that’s almost always your edits. The lines between ======= and >>>>>>> origin/main are the version from GitHub — usually your teammate’s edits. Git is showing you both and asking you to choose.
Resolving the conflict
- Decide what the file should say. Sometimes it’s your version, sometimes it’s your teammate’s, sometimes it’s a combination of both. Sometimes a quick Slack message — “Did you mean 131.4 or 133.2?” — is the right move before you decide.
- Edit the file in RStudio. Delete the conflict markers (
<<<<<<<,=======,>>>>>>>) and leave only the version you want. Save the file. - Switch back to GitHub Desktop. The conflict marker on the file disappears.
- Commit the resolution. GitHub Desktop will offer a default commit message like
Merge branch 'main' of github.com/.... You can accept it as-is or write something more descriptive (Resolve SBP-mean conflict in wrangling section). - Push. The team’s history now includes both your work and your teammate’s, plus your resolution.
Conflicts feel scary the first time. That reaction is completely normal. After the third or fourth one, they start to feel routine. The most important things to remember are: don’t panic, don’t delete the file, don’t force-push. Just edit the file into the version you want and commit the resolution.
Commit message hygiene
Every commit you make becomes a permanent line in your repository’s history. Six months from now, you (or a teammate, or your future advisor) will scroll through the history looking for when did we change the regression model? — and your commit messages are the only thing that will help.
| Bad | Better |
|---|---|
Update |
Drop participants under 18 from analytic sample |
fix |
Fix legend title in main bar chart |
more changes |
Add gender × age-group interaction to wrangling chunk |
final |
Set final figure caption per professor's feedback |
A useful template for a commit message: a verb in the imperative, followed by what changed, optionally followed by why. “Add age-group recoding to wrangling chunk so adults can be filtered by life stage.” The “why” part is what makes a commit message valuable to future-you.
A few rules of thumb (the don’ts)
- Don’t push broken code. Before you push, render your
.qmdto confirm it still builds. If the render fails, fix it before pushing. Pushing broken work means the next teammate who pulls it has a broken project too — and they may not realize the breakage is yours, not theirs. - Don’t push the
data/folder. This is already handled for you by the project’s.gitignore(M02 covers this) — but a teammate who edits the.gitignoreor creates a new repo from scratch can accidentally undo the protection. If you seedata/showing up in the Changes list in GitHub Desktop, stop and ask before committing. - Never force-push
main. A force-push rewrites the shared history and can erase a teammate’s commits. GitHub Desktop will sometimes ask about “forcing” a push when its normal one is blocked. In this course the answer is always no. Pull, resolve any conflicts, and push normally — and if GitHub Desktop insists a force-push is required, stop and ask for help rather than agreeing to it. - Don’t commit credentials. API keys, passwords, anything secret should never enter your repository. If you accidentally commit a secret, treat it as compromised — change the credential immediately and ask the instructor for help getting it out of the history. (For PSY 652 group projects this rarely comes up — but the habit matters for your future career.)
Daily checklist for collaborative work
Every group-project work session
Before you start:
- Open GitHub Desktop before RStudio.
- Click Fetch origin. If “Pull origin” appears, click it.
- Now open RStudio.
While you work:
- Stay in the file(s) your team has assigned you.
- Commit every time you finish a coherent chunk (a figure, a wrangling step, a paragraph). Write a real commit message.
- Render your
.qmdperiodically to make sure it still builds.
Before you stop:
- Render one last time. Fix any errors.
- Commit your final changes.
- Click Push origin.
- Tell your teammates what you worked on (Slack, group chat, whatever) so they know what to pull next.