03 / Save and review your work
GitHub, without
the guesswork.
Understand repositories, branches, commits, and pull requests through one small practice project.
Git and GitHub are different
Git keeps change history on your computer. GitHub hosts repositories online and adds collaboration, pull requests, and automated checks. You can use Git without GitHub. The normal browser-based Claude Code onboarding uses GitHub.
Create your first repository in the browser
Create a GitHub account
Sign in at github.com. Enable two-factor authentication for the account.
Create the repository
Use New repository. Name it claude-practice, select Private, and initialize a README. A license controls how others may reuse code; choose one deliberately if you later publish your project.
Connect it to Claude
Follow the browser walkthrough. For a local workflow, install Git and optionally the GitHub CLI, then clone your repository.
Use the same project locally
Install Git and, for the gh commands, GitHub CLI. Replace YOUR-USERNAME with your real GitHub name.
gh auth login
gh repo clone YOUR-USERNAME/claude-practice
cd claude-practice
git switch -c learn/first-change
claude --permission-mode planClaude’s login and GitHub’s login are separate. gh auth login authorizes GitHub operations. Do not paste the resulting token into chat.
Save, push, and review
After your change, inspect the diff before staging. The example assumes you changed README.md; substitute the files you intentionally want to include.
git status
git diff
git add README.md
git diff --cached
git commit -m "Clarify project setup"
git push -u origin learn/first-change
gh pr create --base main --title "Clarify project setup" --body "Adds beginner setup instructions."If Git requests an identity, configure user.name and user.email with your own details. GitHub provides a no-reply email if you prefer to keep your address private.
| Command | Plain-English meaning |
|---|---|
git status | Which branch am I on, and which files changed? |
git diff | What unstaged lines changed? |
git add FILE | Select a file’s changes for the next snapshot. |
git commit | Create a local snapshot. |
git push | Send commits to the remote repository. |
git pull --ff-only | Bring in remote changes only when Git can move forward without making a merge commit. |
gh pr view | Inspect the pull request associated with this branch. |
gh pr checks | Check the pull request’s automated checks. |
Before you merge
- Read all changed files, including configuration and dependency changes.
- Check test results for the latest commit, not an earlier green run.
- Try the visible behavior yourself. A green test does not prove the whole app works.
- Resolve review feedback and conflicts. Ask for an explanation before accepting unfamiliar changes.
- Merge in GitHub once satisfied. Then update your local main branch.
git switch main
git pull --ff-onlyIf something goes wrong
Stop before running destructive commands. git status and git diff help identify the state. For a shared commit, ask about a reviewed git revert rather than rewriting shared history. Uncommitted edits need separate care; not every deleted file can be recovered.
Add local secret files such as .env to .gitignore, but remember this does not remove files already tracked. If a credential was committed, rotate it immediately; deleting the visible line does not remove it from history.
Official references: GitHub Hello World ↗ · Getting started with Git ↗ · GitHub Actions integration ↗
Was this chapter useful?
Report an errorVotes are shared only if you enable optional measurement in Privacy settings.