AI Learning Hub › Learn AI › Self-Paced Courses › GitHub Without the Jargon › GitHub and Your Computer

Module 8 ยท Beginner

GitHub and Your Computer

Clone a repository, see what origin names, fetch without changing your branch, and push -- watching when GitHub changes and when it does not.

By the end

  • Explain the difference between a local and remote repository
  • Explain what cloning does
  • Recognize origin as a name for a remote repository location
  • Inspect which branch is active locally
  • Explain what fetch does without changing the current branch
  • Bring newer main history into a local working branch
  • Explain why changing the local repository does not immediately change GitHub
  • Push updated local branch history to GitHub
  • Verify that the remote branch changed only after the push

If the repository is on GitHub, what does it mean to put it on my computer?

Everything in this course so far has happened in one place. Seven modules, one repository, one address. Module 8 introduces a second location — and with it, the possibility that the two disagree.

This is not a module about learning commands. Commands appear, and you are welcome to ignore their exact spelling. The idea underneath is what matters:

There can be more than one copy of the repository state, and they do not update one another merely because both exist.

Module 7 taught that two branches can hold different history. This module teaches that the same branch can hold different history in two different places.

Local and remote describe where repository state lives, not private versus public, unfinished versus finished, or bad versus good.

Three words to learn

Local repository

A repository stored on the computer you are currently working on.

Remote

A named connection to another repository location that Git can fetch from or push to.

Clone

A local repository created from an existing repository, including its files and history at the time of cloning.

Read the last three words of that third definition carefully. At the time of cloning is the whole module in a phrase. A clone is a copy made at a moment, not a live window onto GitHub.

Words that appear below as operations rather than vocabulary: origin, fetch, pull, push, tracking branch, working tree. You do not need to memorize any of them.

Same project, different locations

On GitHub

The remote repository, hosted online.

  • main, review-note, resource-note;
  • pull request #2; and
  • the repository’s history.

On your computer

The local repository, after cloning.

  • the files, as actual files in a folder;
  • the commit history;
  • which branch is currently checked out; and
  • a note of where the GitHub repository is.

The local repository knows where the GitHub repository is, which does not make them the same object.

One difference worth naming early: pull request #2 appears only in the left column. Pull requests are a GitHub feature, not part of the repository data a clone brings down.

What cloning actually produced

Cloning the practice repository took one command and produced a folder. Inspecting it read-only, with no changes made, showed this:

selected output — immediately after cloning
$ git status
On branch main
Your branch is up to date with
'origin/main'.
nothing to commit,
working tree clean

$ git branch --show-current
main

$ git remote -v
origin  https://github.com/...
        /github-without-the-jargon-
        -practice.git (fetch)
origin  https://github.com/...
        (push)

Selected output. The remote address is shortened and wrapped here; the real output is one line each for fetch and push. Nothing substantive has been altered.

Four things came out of that, and GitHub’s documentation predicts every one:

origin is a name, not a magic place

When Git cloned this repository it created a remote, and by convention called it origin.

In this exercise, origin points to the GitHub-hosted practice repository. GitHub’s own phrasing is unpretentious: a remote URL is “Git’s fancy way of saying ‘the place where your code is stored’,” and “your default remote is usually called origin.”

origin is a convenient local name for that remote location.

Two things not to conclude. Not every remote is called origin — it is a default, not a rule. And a remote does not have to be GitHub; it is a repository location, which in this exercise happens to be on GitHub.

The clone begins on the default branch

The local repository opened on main, and its README matched GitHub’s main exactly — including Module 7’s newer Status line, and no Resource note:

local README on main
Current status: Main changed
after the branch began.

The clone also knew about the other branches on GitHub — they appeared in the branch listing — but their files were not on screen, because a repository shows you one branch at a time locally just as it does in the browser.

Switching to the working branch locally

There was no local resource-note branch yet, only the clone’s record of GitHub’s. One command created a local branch from it and switched to it:

creating the local working branch
git switch --track origin/resource-note
Switched to a new branch
'resource-note'
branch 'resource-note' set up to
track 'origin/resource-note'.

The README then showed the branch’s version — the older Status text, plus the Resource note — matching GitHub’s resource-note exactly. Working tree clean, nothing modified.

Two names that look annoyingly similar

resource-note

The local branch checked out on this computer.

origin/resource-note

This computer’s record of the resource-note branch at the remote named origin.

One is where you are working locally. The other helps Git remember what it last learned about the branch on GitHub.

That is as far as this course takes the distinction. It is enough to read the messages Git prints.

Fetch first, and watch what does not happen

Before combining anything, ask GitHub for newer information:

git fetch origin
$ git fetch origin
$

That is the entire output. Nothing. The clone was fresh, so there was nothing newer to learn, and Git said so by saying nothing at all.

Everything checked afterwards was unchanged: still on resource-note, README still showing the older Status line, working tree still clean.

GitHub’s documentation explains why, and the emphasis is theirs: fetching “grabs all the new remote-tracking branches and tags without merging those changes into your own branches.” Fetch updates what your local repository knows without automatically merging that information into the branch you are working on.

A note on pull

You will meet a command called git pull, and GitHub describes it accurately as “a convenient shortcut for completing both git fetch and git merge in the same command.”

This module deliberately does not use it. Doing the two ideas separately lets you see which stage changes what — and the answer, as above, is that one of them changes nothing you can see.

Convenience is easier to understand after you can see the pieces.

There is nothing wrong with pull. Most people use it most of the time.

Bringing newer main into the local branch

With resource-note checked out and the working tree clean, one command combined the newer main history into it:

git merge origin/main
$ git merge origin/main
Auto-merging README.md
Merge made by the 'ort' strategy.
 README.md | 2 +-
 1 file changed,
 1 insertion(+), 1 deletion(-)

Auto-merging. Module 7 predicted this: the two edits touched different parts of the file, so Git combined them without asking anyone to decide anything. Had it reported a conflict instead, this is where the work would have stopped.

The local README now contained both changes at once — the newer Status sentence from main, and the Resource note from the branch. And Git created a commit to record the combination, exactly as the merge in Module 6 did.

The local repository changed. GitHub did not.

This is the center of the module, and it is worth pausing on before going any further.

At this moment, two things were true at the same time:

Local resource-note

Current status: Main changed after the branch began.

Plus the Resource note, plus a new merge commit.

GitHub resource-note

Current status: Ready for review.

Plus the Resource note. No new commit.

Opening the branch on GitHub in a browser confirmed it: the older sentence, still there, at the same commit as before.

Git itself was explicit about the situation:

git status, after the merge
On branch resource-note
Your branch is ahead of
'origin/resource-note' by 2 commits.
  (use "git push" to publish
   your local commits)

nothing to commit,
working tree clean

A local commit is not automatically a GitHub commit just because the repository originally came from GitHub.

Be precise about what that means. The merge commit is real. It exists, in Git, on this computer. It is simply not part of the branch on GitHub — and nothing will make it so except a deliberate act.

Same branch name. Different locations.

Notice what Module 7’s vocabulary does here. The local branch and the GitHub branch share a name, and the names being equal tells you nothing about the histories being equal. The branch names match; their current histories do not, yet.

Publishing local branch history

The deliberate act is push. In GitHub’s words: “Use git push to push commits made on your local branch to a remote repository.” It takes two arguments — a remote name and a branch name.

the command, and what each part names
git push origin resource-note
          |      |
          |      the branch
          the remote

Direction: computer → GitHub. That is the same kind of question Module 7 asked about updating versus merging, and it is worth answering out loud every time.

Running it produced one line:

git push origin resource-note
To https://github.com/...
   c0d6504..b5950a4
   resource-note -> resource-note

Selected output. The address is shortened. Those two short codes are the branch’s position before and after — you do not need to read them, only to notice that something moved.

Now GitHub has changed

Back in the browser, read-only, the same branch page as before:

Before the push

  • Current status: Ready for review.
  • 1 commit ahead of main, 1 commit behind.

After the push

  • Current status: Main changed after the branch began.
  • 2 commits ahead of main, and no longer behind.

The behind count went to zero because the branch now contains main’s newer commit. Nothing about main changed; the branch caught up to it.

History can change more than the difference

Pull request #2 was watched across the push, and what happened to it is more interesting than it first looks.

Commits
1 → 2. The header line changed from “wants to merge 1 commit” to “wants to merge 2 commits.”
Files changed
1, unchanged.
Additions and deletions
+4, unchanged.
The diff itself
The same four added lines — the Resource note, and nothing else.
Mergeability
Still “No conflicts with base branch.”
State
Still Open, still unmerged.

So the proposal got a commit longer while proposing exactly the same change. That is not a contradiction:

Commit history and the current file difference are related, but they are not the same measurement.

One small detail rewards attention. The unchanged context line at the top of the diff used to read Current status: Ready for review. After the push it reads Current status: Main changed after the branch began. — because that sentence is no longer a difference between the branch and main. It is now common ground, so it appears as context rather than as a change.

Three directions to keep straight

Fetch

GitHub → local knowledge

Gets newer remote information. Does not by itself change the checked-out branch.

Merge

local history → local branch

Here: origin/main into local resource-note.

Push

local branch → GitHub

Here: local resource-note to origin/resource-note.

Fetch learns. Merge combines. Push publishes.

Local does not mean offline, and remote does not mean GitHub

Two quick corrections, because the words carry baggage.

A local repository is defined by where the repository lives — on the computer in front of you. It is not a claim that you are offline, and not a claim that the work is private or unfinished.

A remote is a named connection to another repository location. In this exercise that location is GitHub. It does not have to be.

Save, commit, push

Module 3 separated saving from committing. The local repository adds a third step, and keeping all three apart is genuinely useful:

  1. Edit a file.
  2. Save it to disk. The file on your computer changes.
  3. Commit locally. The local repository’s history changes.
  4. Push. The remote branch changes.

Save changes a file. Commit records repository history. Push publishes local history to a remote.

Our merge commit was created locally without anyone editing or saving a file at all — which is a reminder that repository history can be made by operations, not only by typing.

Why this matters for AI coding tools

Module 9 takes this up properly, but the connection is worth making now, while the two locations are fresh.

Tools such as coding agents often operate on files in a local repository. That means an AI can alter local files, or even create local commits, without any of it appearing on GitHub. Whether anything reaches GitHub depends on what the tool is able to do and what it has been permitted to do.

Local is a real state worth inspecting rather than merely a waiting room for GitHub.

Local or GitHub?

A learner merges origin/main into their local resource-note but has not pushed. Where does the new merge commit exist?

pick one
A. Only on GitHub

B. Only in the local repository

C. Automatically everywhere with
   that branch name
One possible answer

B — only in the local repository.

The commit is real and complete; it simply exists in one place. A has it backwards. C is the assumption this module exists to dislodge — a shared branch name is not a shared state.

After a successful push, the remote branch can receive that history too. Until then, closing the laptop is the only thing standing between the commit and nobody else ever seeing it.

What does fetch change?

After running git fetch origin, which is the best description?

pick one
A. It automatically edits the
   current files to match GitHub.

B. It retrieves newer remote
   information without automatically
   merging it into the checked-out
   branch.

C. It publishes local commits.
One possible answer

B.

A describes something closer to merge, and would be alarming if true — a command that silently rewrote your working files whenever someone else pushed would be very hard to work with. C describes push, which moves in the opposite direction.

In our run, fetch printed nothing and changed nothing visible. That is a normal, successful fetch.

Which direction?

name the direction
Fetch                    ?

Push                     ?

Merge origin/main while
on local resource-note   ?
One possible answer

Fetch: GitHub → computer. Information comes to you.

Push: computer → GitHub. Your commits go out.

Merge: the local repository changes immediately. Nothing leaves your computer and nothing arrives from GitHub — the combination happens between two lines of history Git already has. Knowing the direction is often more useful than memorizing the command.

Four different verbs

Match each verb to what it does.

match them up
Save     Commit     Fetch     Push

- write current file contents
  to disk
- record repository history
- retrieve newer remote
  repository information
- publish local commits
  to a remote
One possible answer
  • Save — write current file contents to disk.
  • Commit — record repository history.
  • Fetch — retrieve newer remote repository information.
  • Push — publish local commits to a remote.

The point is not the pairing, which is easy. It is that these are four separate events, each of which can happen without the next one following. A file can be saved and never committed. A commit can exist for weeks and never be pushed. Most confusion about Git is really confusion about which of these four has actually happened.

What to notice

Once a repository exists in two locations, two questions keep you oriented:

Where am I looking?

The local computer, or GitHub?

Which direction is information moving?

Remote to local? Within local history? Local to remote?

A matching branch name does not guarantee matching repository state.

Before you continue

You are ready for Module 9 if you can: