AI Learning Hub › Learn AI › Self-Paced Courses › GitHub Without the Jargon › When Someone Else Changes the Project
Module 7 ยท Beginner
When Someone Else Changes the Project
What ahead and behind mean, why branches with identical files can hold different histories, and how divergence differs from a conflict.
By the end
- Explain what ahead and behind mean on GitHub
- Explain why branches with the same visible files can still have different histories
- Recognize when two branches have both moved
- Distinguish divergence from a merge conflict
- Explain why different changes can often be combined automatically
- Recognize what it means for a pull-request branch to be behind its base
- Know what evidence to inspect before bringing newer base-branch work into your branch
- Explain why updating a branch is different from merging its pull request
The file matches. The history does not.
Module 6 ended on a success: the Review note reached main, verified by looking at main. But something was left behind, and it is strange enough to start here.
main
4 commits.
Contains the Review note.
review-note
3 commits.
Contains the Review note.
Same section, same wording, same file. And yet GitHub reported that review-note was 1 commit behind main. How can a branch be behind if the file looks the same?
The answer is in Module 6’s commit count. The Review note reached main through pull request #1 — and the merge itself created another commit on main. That merge commit does not exist on review-note. One branch has a commit the other lacks, even though the two produce identical text.
Ahead and behind describe commit history, not whether the files happen to look different right now.
That is the first lesson. The second is the one this module is really about:
What happens when main changes while you are still working on another branch?
Three words to learn
Ahead
A branch is ahead of another branch when it contains one or more commits the other branch does not.
Behind
A branch is behind another branch when the other branch contains one or more commits it does not.
Merge conflict
A situation where Git cannot automatically combine competing changes and needs a decision about what the resulting content should be.
Ahead and behind are two directions of the same comparison, always measured against a named other branch. A branch is never simply “behind” — it is behind something. Still not needed: merge base, fast-forward, fetch, pull, origin, remote, upstream, rebase, and conflict marker.
“Behind” is a relationship, not a warning label
The word sounds like a reprimand. It is not one.
Behind does not mean the branch is broken, unsafe, incorrect, or abandoned. It means one thing only: another branch contains commits this branch does not.
Whether that matters depends entirely on what those commits contain and what you plan to do next. A branch that is behind by one unrelated typo fix is in a very different position from one that is behind by a change to the exact lines it touches.
Start from what we already have
Rather than reuse review-note — which has finished its job and was the source of a merged proposal — the scenario below starts a fresh branch from the current main: resource-note.
One honesty note before the scenario. For this disposable exercise, we are making both changes from the same account so we can reproduce the situation safely. In real collaborative work, the newer main change might come from another person, another pull request, automation, or another work session. Nobody else participated here.
The sequence, in order:
- A branch is created from the current
main. At this moment it matchesmainexactly. - Work is committed on the branch. A Resource note is added to the README. The branch is now 1 ahead, 0 behind — verified, not assumed.
- Then
mainchanges. The Status sentence is edited, onmain, after the branch already had work on it.
That third step is the whole point. It is the moment your starting assumption stops being true.
Both branches moved
After those three steps, the two branches hold different things:
Only on resource-note
## Resource noteThis note was added on the working branch.
Commit: Add resource note
Only on main
Current status: Main changed after the branch began.
Commit: Update practice status
Each has one commit the other lacks. GitHub says so in a single sentence on the branch page:
This branch is 1 commit ahead of
and 1 commit behind main.
Shown on two lines here to fit a narrow screen; on GitHub it is one sentence.
A branch can be ahead and behind at the same time.
The two counts answer two different questions, and there is no reason both cannot be yes:
- Ahead
- Does this branch have commits the other branch lacks?
- Behind
- Does the other branch have commits this branch lacks?
The two branches have now moved in different directions. That is the ordinary condition of collaborative work, not an error state.
Observed on GitHub
Verified: 21 September 2026.
This is the disposable private practice repository. The branch shown is resource-note, compared against the default branch main, in the state described above: one commit on each side that the other does not have. The #2 at the right is the open pull request proposing this branch’s work.
The pull request was left open and the branch was left unsynchronized. Nothing was updated, merged, or resolved. GitHub’s labels and layout may change.
Two branches can both change without fighting over the same change
Here is the thing most people expect at this point, and it is wrong: that two branches moving in different directions must be a problem.
Look at what the two edits actually touched. resource-note added a new section at the end of the file. main changed one existing sentence in the middle. Different lines, different parts of the file.
GitHub’s documentation is direct about this: “Usually, changes are on different lines or in different files, so Git can merge them without help.” Different changes are not automatically conflicting changes.
The Compare view for these two branches confirmed it in this case: Able to merge. These branches can be automatically merged.
“Usually” and “in this case” are doing real work in those sentences. Edits on different lines are the common case for automatic combination, not a guarantee that any two different edits will always combine cleanly.
Sometimes Git cannot choose for you
A merge conflict is what happens when automatic combination is not possible. In GitHub’s words, conflicts “block merging because Git cannot safely choose which version of the conflicting content to keep.”
The classic case is two branches changing the same line differently. Imagine the original line:
original
Current status: Ready for review.
branch A changes it to
Current status: Ready to publish.
branch B changes it to
Current status: Needs another review.
Both branches replaced the same original content, differently. There is no rule that tells Git which one wins, because that is not a technical question. Somebody has to decide what the line should say. A conflict is a need for a content decision rather than proof that somebody made a mistake.
GitHub also names a second common case that is not about lines at all: “one person edits a file and another person deletes the same file.” Keep the edit, or accept the deletion? Again, a decision, not a calculation.
Where a conflict is simple, GitHub can sometimes handle it in the browser. Where it is not, its documentation says “more complex conflicts must be resolved in a local clone and pushed back to the pull request branch” — which is a good preview of why Module 8 exists.
Behind and conflicting are different things
Behind
The other branch has commits you do not have.
A statement about history.
Conflict
Git cannot automatically determine how competing changes should be combined.
A statement about content.
They are independent. A branch can be behind with no conflict — which is exactly our case. It can be ahead and behind with no conflict, also our case. It can be behind and conflicting. Or it can be fully up to date with nothing outstanding at all.
What the comparison shows, and what it leaves out
The Compare view for main and resource-note reported 1 commit, 1 file changed, and 4 additions and 0 deletions — the Resource note, and nothing else.
Notice what is not in that diff. The newer Status sentence on main does not appear, and its unchanged context line in the diff still reads the older text.
The comparison is showing what resource-note proposes to bring into main. The newer Status change already belongs to main; it is not itself part of the branch’s proposal.
This trips people up. A comparison between two branches is not a neutral side-by-side of everything that differs between them — it is oriented, like the pull request it supports.
Mergeable still answers a narrow question
GitHub said these branches can be automatically merged, and that remains exactly as narrow a statement as Module 6 said it was. It means GitHub can combine this particular set of edits without asking anyone to resolve competing content.
It does not mean the branch contains the latest main history, that the proposal has been reviewed, or that the change should be merged.
The proposal is open, and the branch is still behind
A pull request was opened for this work — #2, from resource-note into main, still open. And here is something worth noticing about where GitHub reports what.
The branch page says the branch is 1 ahead and 1 behind. The Branches list has columns headed exactly Behind and Ahead, showing 1 and 1. But the pull request page itself said nothing at all about being behind. Its merge box simply read No conflicts with base branch, with the ordinary merge button.
No Update branch control appeared on our pull request. GitHub’s documentation explains why that is unremarkable: the option shows up “when there are no merge conflicts and the branch is behind the base branch” — and its availability also depends on repository configuration, such as a rule requiring branches to be up to date before merging, or a setting that always suggests updating. This disposable repository has neither, so no button. That is configuration, not an error, and we did not change any setting to make one appear.
Opening this second proposal also drew another automated comment from the same integration Module 6 discussed, without anyone asking for it. Automated repository integrations may react when collaboration state changes — though most repositories have nothing connected that would.
Updating and merging move in opposite directions
This is the distinction to carry into Module 8, and it is easy to blur because both involve the words merge and branch.
Updating the working branch
main → resource-note
Brings newer base-branch work into your branch, so your branch is no longer behind.
Merging the pull request
resource-note → main
Brings your proposed work into the base branch, which is what the proposal asks for.
Updating the working branch and merging the pull request move changes in different directions.
Neither was performed here. Where GitHub does offer an update, its documentation describes two ways of doing it — a traditional merge, or a rebase that produces a history without a merge commit. This course is not teaching that choice yet.
We are stopping with the problem still visible
This is deliberate. As Module 7 ends:
maincontains a changeresource-notedoes not;resource-notecontains a changemaindoes not;- pull request #2 proposes one direction; and
- the branch is still missing newer
mainhistory.
Nothing here is broken. It is simply unfinished, in the specific way real work is usually unfinished. Before we fix the state, we need to understand where a repository can live and how changes move between GitHub and your computer.
Can a branch be behind when the file looks the same?
Back to where this module started. After pull request #1 was merged, main and review-note showed the same README — and review-note was still one commit behind.
How can both be true?
One possible answer
The merge created a new commit on main — a merge commit recording that the combination happened. The file content matched, because that merge brought in exactly the change the branch already had. But the commit histories did not match, because review-note never received that merge commit. File content and commit history answer different questions.
“What does this file say?” and “what has happened to this project?” are not the same question, and GitHub will happily tell you two different-sounding answers to them at the same time.
Ahead, behind, or both?
resource-note contains the commit Add resource note, which main lacks. main contains Update practice status, which resource-note lacks.
A. only ahead
B. only behind
C. both ahead and behind
D. neither
One possible answer
C — both.
Ahead, because resource-note has Add resource note and main does not. Behind, because main has Update practice status and resource-note does not.
The two counts are independent measurements. Answering one does not constrain the other, which is why GitHub shows them as two separate numbers rather than a single position on a line.
Conflict, or just different?
Four situations. Which are most likely to need a human content decision?
A. Branch changes the README title.
Main changes a separate footer
section.
B. Branch changes one Status
sentence to "Ready."
Main changes the same sentence
to "Not ready."
C. Branch adds resources.md.
Main edits README.
D. Branch deletes a file while
main edits that same file.
One possible answer
B and D are the classic conflict situations.
B is two different replacements of the same content — the case GitHub describes as “different changes to the same line of the same file.” D is the other case it names: one side edits a file, the other deletes it. Keep the edit or accept the deletion is a decision nobody can compute.
A and C can often be combined automatically, because the changes do not compete for the same content. A is different parts of one file; C is different files entirely.
Note the hedging, which is deliberate. Often and likely, not always and never — the shape of a change is a good predictor of whether it will combine cleanly, not a guarantee.
What are you trying to update?
main has newer project work. resource-note has your proposed work.
If you want your working branch to learn about the newer main work, which direction is the information moving? And if you later merge the pull request?
One possible answer
Updating your branch: main → resource-note. The newer base-branch work comes to you.
Merging the pull request: resource-note → main. Your proposed work goes to the base branch.
Updating the branch and merging the proposal solve different problems.
Updating solves “my branch does not know about recent work.” Merging solves “my work is not in the project yet.” You can need both, either, or neither, and doing one never does the other for you.
What to notice
Branches are not frozen snapshots of the whole project. Other work can continue while yours is in progress. When it does, three questions keep you oriented:
What does my branch have that main does not?
Ahead.
What does main have that my branch does not?
Behind.
Can Git combine both sets automatically?
If not, there may be a conflict requiring a decision.
Collaboration means the state you started from may not be the state you finish against.
Before you continue
You are ready for Module 8 if you can:
- explain ahead and behind in terms of commits;
- explain why identical visible files can still have different histories;
- explain how a branch can be ahead and behind simultaneously;
- distinguish being behind from having a merge conflict;
- explain why different changes can often be combined automatically;
- recognize when a same-content decision may require human resolution;
- identify which direction an update would move changes;
- distinguish updating the working branch from merging its pull request; and
- explain why pull request #2 is intentionally left open and unsynchronized.