Skip to content

Using GitHub

See how Git on your computer connects to GitHub and the team. Then explore the concepts and follow a change into shared use.

How Git and GitHub work together

Git runs on each computer. GitHub holds the shared repository. Follow one change from your working files, through review, into a teammate's copy.

1 / 8
Git on each computer, GitHub shared by the teamThree workstations each contain working files, staging and local Git history. Clone, push and pull connect them with GitHub. On GitHub, a pull request connects the feature branch to main. Your computerLOCAL GITWorking filesCurrent filesStagingNo staged editsLocal Git historyAMaya's computerLOCAL GITWorking filesCurrent filesStagingNo staged editsLocal Git historyALeo's computerLOCAL GITWorking filesCurrent filesStagingNo staged editsLocal Git historyAGitHubThe shared repositoryfix-researchEmptymainAclonegit addgit commitpushPR review + mergepullpush / pull

One team, separate local histories

Git runs on each computer. GitHub holds the shared repository.

A and B are commits. Δ is an uncommitted edit. Red shows the current transfer. Choose any step or play the whole flow.

Git and GitHub have different jobs
CompareGitGitHub
What it isThe version-control tool that records your project history.A service that hosts Git repositories and team collaboration.
WhereOn each computer, using its local repository.A hosted service accessed through Git tools and your browser.
What you doStage changes, commit, branch and merge.Share branches, open PRs, review changes and run checks.
OfflineLocal edits, commits and branches work without an internet connection.Exchanging commits with GitHub and using its online reviews needs a connection.

You can use Git without GitHub. GitHub is one option for hosting and collaborating on Git repositories. git status inspects your current changes. git log shows recorded commits.

Key concepts

Git records your project's history. GitHub hosts a shared repository and the team's reviews. Start with the files on your computer, then follow what each action changes.

Repository and clone

"Give me my own copy to work on."

A repository is a project plus its Git history. Cloning copies a repository from GitHub to your computer.

Your computer

No local copy yet
← Cloneorigin

GitHub

skills/research/SKILL.md
AB

Shared files + history

Start with the shared repository on GitHub. Clone it to get your own local copy.

Stage and commit

"Choose the changes, then record a checkpoint."

Editing changes a file. Staging selects what the next commit will contain. The commit records that selection in local history.

All three states are on your computer.

Working file

List the sources.

research/SKILL.md

Staging area

No change selected

git add

Local history

git commit

Branch

"Let me develop this change on its own line."

A branch is a name pointing to a commit. Create one, then watch its name advance when you commit on it. main is a common name for the team's integrated branch.

Push and pull

"Share my commits. Bring back the team's commits."

The two repositories can have different histories. Push sends commits to a remote branch. Pull fetches remote commits and integrates them into your current local branch.

Your computer

fix-research
Push →

GitHub

fix-research

Pull request and merge

"Review this change before it joins main."

A pull request, or PR, proposes a merge. Reviewers inspect the changes and checks. Merging integrates the reviewed work into the target branch.

Require links in research

Open for review

fix-research → main · commit B

− Summarise findings.+ Summarise findings with source links.
Shared main

Branches and worktrees work together

A branch names a line of work. A worktree is the folder where its files are open. Watch one folder switch branches, then keep two tasks open in separate folders.

1 / 7
One folder opens one branchMaya starts on main. The folder shows the files recorded at A. The local repository holds the history and branch names. One local Git repositorymainAmaya/skills/mainresearch/SKILL.mdFiles at ANo extra worktree yetOne working folder

Illustrative example. Controls change no real files or repositories. Use Play, the step buttons or the left and right arrow keys.

Your normal checkout already has a working tree. Extra worktrees share its local repository history and branch names. Another computer usually has a separate clone. Git normally prevents one branch being checked out in two worktrees at once.

Building in a shared repo

Follow Maya and Leo from separate local changes to a shared release. Try different files, overlapping edits and a workflow whose output and input disagree.

1 / 10
Separate computers start from AMaya and Leo have their own clones. GitHub holds shared main at A. Their local work does not change another computer automatically. Maya's computermainresearch/SKILL.mdFiles at AALeo's computermainreport/SKILL.mdFiles at AAGitHubresearch-updateEmptyNo new editreport-updateEmptyNo new editNo pull requests yetmainARelease bundleNot builtInstalled skillsPrevious release

Illustrative example. Controls change no real files or repositories. Use Play, the step buttons or the left and right arrow keys.

Uploaded, merged and available are different states

Follow version 2 through the release process. Watch the live version stay at 1 until publication finishes. Then compare a separate release with automatic publication.

1 / 6
Users have version 1The local change will become version 2. Shared main and production still have version 1. This is an illustrative release process. Shared GitHubmain · v1Checks and buildNot runPrepared bundleNo new bundleLive servicev1 liveLocal v2buildpackagepublish

Illustrative example. Controls change no real files or repositories. Use Play, the step buttons or the left and right arrow keys.

The repository configuration determines the real trigger. A push or merge may start checks and deployment. A successful build may still wait for approval. A PR preview can be separate from production. Some teams update installed skills through a synchronised checkout.

Check your understanding

Try these without reopening the definitions. Each answer gives immediate feedback.

Maya wants an urgent fix and her unfinished task open in separate folders. What does she add?

The changes touch different files and Git reports no conflict. Does that prove the workflow works?

The branch was pushed. Are its new skills available to users?

Say hello

Draft a message about the work you need to complete.

Local draft preview. No message is sent. Review the draft, then copy it for use elsewhere.