GitHub Exercises with Answers
Practise GitHub with 110 interactive exercises: multiple choice, fill-in-the-blank, output prediction and debugging. Every exercise gives instant feedback, a hint and the full solution.
Topic All topics Introduction Repositories Markdown & README Profile & Portfolio SSH & Authentication Push, Pull & Clone Issues Pull Requests Code Review Forks & Open Source Templates & Community Files Projects & Discussions Gists & Wikis GitHub Pages GitHub Actions Releases Organizations & Teams Security Codespaces GitHub CLI GitHub CODEOWNERS Patterns and Review Requirements GitHub Repository Rulesets and Merge Queue Checks GitHub Actions Contexts, Expressions and Job Outputs GitHub Reusable Workflows with Typed Inputs and Outputs GitHub Actions Dependency Caches and Workflow Artifacts GitHub Actions Permissions and Untrusted Pull Requests GitHub Environments and OIDC Deployment Identity GitHub REST API Pagination with Bounded Clients GitHub Issue Forms for Useful Reports and Triage GitHub Container Registry Packages and Image Identity
All types Fill in the blanks Multiple choice Predict the output
Any level Easy Medium Hard
Score 0 / 110
What is a fork on GitHub?
A A deleted repository B A branch inside your repository C Your own copy of someone else's repository D A type of issue
Forks let you experiment with and propose changes to projects you don't own.
Show answer
Which statement about Git and GitHub is true?
A Git tracks changes locally; GitHub hosts repositories online B GitHub works without Git C Git is a website and GitHub is a program D You must use GitHub to make commits
Commits are made with Git; GitHub stores and shares them.
Show answer
What does https://github.com/ada/notes/pull/12 point to?
A The 12th commit of ada's notes B Issue 12 of ada's notes C The notes repository's 12th branch D Pull request 12 in ada's notes repository
/pull/ pages are pull requests.
Show answer
What's the main difference between Git and GitHub?
A They're the same thing B Git tracks changes on your computer; GitHub hosts repositories online and adds collaboration tools C GitHub is a newer version of Git D Git only works with GitHub
You can use Git without GitHub.
Show answer
Who can see a private repository?
A Everyone on GitHub B Only GitHub staff C Only you and the people you invite D Anyone with your username
Private repositories are visible only to invited collaborators.
Show answer
Why add a licence such as MIT to a public project?
A It makes the repository faster B It tells others what they're allowed to do with your code C GitHub won't publish it otherwise D It hides the code
Without a licence, others have no permission to reuse the code.
Show answer
What happens to a line ## Installation in a README?
A It's shown as two hash signs B It's hidden as a comment C It becomes a link D It becomes a second-level heading
## is a smaller heading than #.
Show answer
Which visibility lets only you and invited people see a repository?
A Private B Public C Internal to GitHub staff D Hidden
You can change visibility later in Settings.
Show answer
Complete the Markdown for a second-level heading.
Installation
Two hash characters and a space make a level 2 heading.
Check answer Show solution
Which Markdown makes text bold?
A text B _text_ C #text# D <b>text
Two stars on each side.
Show answer
Which line is a correct Markdown link?
A (Codevra)[https://www.codevra.org] B Codevra C <Codevra>(https://www.codevra.org) D {Codevra}[https://www.codevra.org]
Text in square brackets, address in round brackets.
Show answer
What does - [ ] Write tests show in a GitHub issue?
A A link B A heading C An image D An unticked checkbox with the text "Write tests"
It's a task list item; [x] would show it ticked.
Show answer
How do you get syntax highlighting for a block of Python code?
A Indent it with a tab B Put it in bold C Use a fenced code block starting with three backticks and the word python D Start each line with >
The language name after the backticks selects the highlighter.
Show answer
For the user ada, what must the special profile repository be called?
Repository name:
The repository must match the username exactly.
Check answer Show solution
How many repositories can you pin to your profile?
A 3 B 10 C Unlimited D 6
Choose your six best.
Show answer
What's the most effective thing to add to a project README?
A A long list of badges B Your full CV C A screenshot and a live demo link D Every commit message
People can see your work in one click.
Show answer
Why might your commits not appear on your contribution graph?
A The email in your Git config isn't one of your GitHub account's emails B They were too small C You pushed on a weekend D The repository has no README
GitHub links commits to accounts by email.
Show answer
What should you do with old experiments you don't want to be judged by?
A Delete your account B Archive them or make them private C Pin them D Rename them to final
Keep the profile focused on your best work.
Show answer
Complete the command that creates a new SSH key.
-t ed25519 -C "sam@example.com"
ssh-keygen generates a private and public key pair.
Check answer Show solution
Which file do you add to GitHub?
A id_ed25519.pub B id_ed25519 C known_hosts D .gitconfig
Only the public key is shared.
Show answer
Which address is an SSH remote?
A git@github.com:ada/notes.git B https://github.com/ada/notes.git C ssh.github.com/ada/notes D github://ada/notes
SSH addresses start with git@github.com: followed by owner/repo.
Show answer
You run ssh -T git@github.com and see "Hi ada! You've successfully authenticated". What does it mean?
A Something went wrong B You need a new key C Your SSH key is set up correctly D Your repository was deleted
The greeting confirms GitHub recognised your key.
Show answer
You cloned with HTTPS but want to use SSH from now on. What's the best command?
A git clone again into the same folder B git remote add ssh-origin C ssh-keygen --switch D git remote set-url origin git@github.com:user/repo.git
set-url changes the existing remote's address.
Show answer
What does git clone <url> do?
A Downloads a full copy of a repository, with its history B Uploads your project C Duplicates a branch D Creates an empty repository on GitHub
Clone copies everything and sets up origin.
Show answer
What's the difference between git fetch and git pull?
A fetch uploads; pull downloads B They're identical C pull only works on main D fetch only downloads; pull downloads and merges
pull is fetch followed by a merge.
Show answer
You run git push and see "rejected (fetch first)". What's the usual fix?
A git push --force B git pull, then git push again C Delete the repository D git init
Pull the commits you don't have, merge them, then push.
Show answer
What does git fetch do that git pull doesn't?
A Uploads your commits B Deletes remote branches C Downloads new commits without merging them into your branch D Nothing, they're identical
pull is fetch followed by a merge.
Show answer
What makes a good issue title?
A "Bug" B "Help!!!" C "Menu doesn't open on iPhone Safari" D "Please fix asap"
A specific title tells everyone exactly what's wrong.
Show answer
Predict the outputmedium Issues What does - [ ] Write tests become in an issue?
A An unticked checkbox B A link C A heading D A label
Markdown task lists render as checkboxes.
Show answer
Which filter shows open issues labelled as bugs?
A bug only B is:open label:bug C open = bug D #bug
GitHub's search filters combine with spaces.
Show answer
Which line in a pull request description closes issue 8 when the PR is merged?
A See #8 B Fixes #8 C Issue 8 done D @8
Keywords like Fixes, Closes and Resolves link and close the issue.
Show answer
A A command that downloads code B A request for access to a repository C A bug report D A proposal to merge one branch into another, with review
PRs collect the changes, discussion and approval in one place.
Show answer
A reviewer asks for a change on your open PR. What do you do?
A Commit the fix on the same branch and push B Close it and open a new PR C Edit main directly D Delete the branch
New commits on the branch update the PR automatically.
Show answer
What happens when a PR whose description contains Closes #8 is merged?
A Nothing special B Issue 8 is closed automatically C PR number 8 is closed D The branch named 8 is deleted
Keywords like Closes and Fixes link and close issues.
Show answer
How do you update a pull request after review feedback?
A Close it and open a new one B Edit the files on main C Email the changes to the reviewer D Push more commits to the same branch
New commits appear in the PR automatically.
Show answer
Complete the command that downloads pull request 15 to review it locally.
gh pr 15
gh pr checkout fetches the PR's branch and switches to it.
Check answer Show solution
Which tab shows a pull request's line-by-line changes?
A Files changed B Conversation C Commits D Checks
Added lines are green and removed lines red.
Show answer
What does a suggestion comment let the author do?
A Delete the PR B Merge without approval C Apply your proposed code change with one click D Change reviewers
The suggestion becomes a commit on their branch.
Show answer
Which review result blocks merging until it's addressed (on protected branches)?
A Comment B Request changes C Approve D Viewed
Request changes signals the PR mustn't merge yet.
Show answer
What does a CODEOWNERS file do?
A Automatically requests reviews from the owners of matching files B Lists who can push to the repository C Records who wrote each line D Locks files so nobody else can edit them
Patterns map files to the people or teams who review them.
Show answer
Complete the command that adds the original project as a remote.
git remote add https: // github. com/ open - kitchen/ recipe- api. git
upstream is the usual name for the original repository.
Check answer Show solution
A Your own copy of someone else's repository on GitHub B A branch on your computer C A merge conflict D A deleted repository
You can push freely to your fork.
Show answer
After forking and cloning, what does origin point to?
A The original project B GitHub's homepage C Nothing until you push D Your fork
You cloned your fork, so origin is your copy.
Show answer
Which commands bring the original project's new commits into your local main?
A git push upstream main B git fetch upstream, then git merge upstream/main C git clone again D git remote update origin
Fetch from upstream, then merge.
Show answer
When opening a PR from a fork, what should the base repository be?
A Your fork B Any repository C The original project D A new empty repository
The base receives the changes; the head is your fork.
Show answer
Complete the path for a pull request template.
.github/
GitHub reads .github/pull_request_template.md for new pull requests.
Check answer Show solution
Where do issue templates go?
A docs/templates B .github/ISSUE_TEMPLATE/ C The repository root only D The wiki
Each file there becomes an option in the template chooser.
Show answer
What does blank_issues_enabled: false do?
A Requires people to choose a template when opening an issue B Deletes empty issues C Closes issues without labels D Hides the Issues tab
It's set in .github/ISSUE_TEMPLATE/config.yml.
Show answer
What's the difference between a fork and a repository created from a template?
A There's none B Templates can't be private C Forks have no files D A template copy is independent with a fresh history; a fork stays linked to the original
Templates are for starting new projects.
Show answer
How can an organisation give all its repositories a default CODE_OF_CONDUCT.md?
A Copy it into every repository by hand B Put it in a repository named .github owned by the organisation C Add it to the organisation's profile picture D It can't
Repositories without their own file use the default.
Show answer
Complete the folder where issue forms are stored.
.github/ /bug_report.yml
GitHub reads issue forms from .github/ISSUE_TEMPLATE.
Check answer Show solution
Which project view shows work as columns of cards?
A Board B Table C Roadmap D Insights
Columns usually come from the Status field.
Show answer
Where should a question like "How do I install this?" usually go?
A A new issue B A commit message C GitHub Discussions D The README's licence section
Discussions keep the issue list for actionable work.
Show answer
What does the "Pull request merged" workflow do?
A Deletes the card B Reopens the issue C Sets the item's Status to Done D Creates a release
It keeps the board accurate without manual moves.
Show answer
Why use a custom Priority field instead of priority labels?
A Labels can't have colours B Fields can be sorted, grouped and filtered in project views, and don't clutter the issue C Labels are deprecated D Fields are visible only to admins
Project fields are designed for planning data.
Show answer
Complete the command that creates a public gist.
gh gist create notes. md --
gh gist create makes secret gists unless you add --public.
Check answer Show solution
A Encrypted and visible only to you B Deleted after a day C Only visible to your organisation D Unlisted: not on your profile or in search, but readable by anyone with the link
Never put sensitive data in any gist.
Show answer
Why give a gist file an extension like .sql?
A It's required to save B It makes the gist public C GitHub uses it to choose the syntax highlighting D It enables comments
Without one, the code is shown as plain text.
Show answer
Which wiki page appears as a menu on every page?
A _Sidebar B Home C Menu D index
_Footer works the same way for a footer.
Show answer
Where should installation steps that change with the code usually live?
A In a gist B In the repository, such as README.md or docs/, updated in the same pull request as the code C Only in the wiki D In issue comments
Then changes to docs are reviewed alongside the code.
Show answer
Complete the name of the file GitHub Pages uses as the home page.
.html
The home page must be called index.html.
Check answer Show solution
Which of these can GitHub Pages host?
A A PHP website with a MySQL database B An HTML, CSS and JavaScript portfolio C A Python web server D A Java application server
Pages serves static files that run in the browser.
Show answer
User ada publishes the repository recipes with GitHub Pages. What's the site's address?
A https://github.com/ada/recipes B https://recipes.github.io/ada/ C https://pages.github.com/ada/recipes D https://ada.github.io/recipes/
The pattern is username.github.io/repository.
Show answer
How do you update a published GitHub Pages site?
A Re-create the repository B Upload files in the Pages settings C Commit your changes and push to the publishing branch D Email GitHub support
Every push republishes the site automatically.
Show answer
Your Pages site shows a 404. What should you check first?
A That index.html is in the folder and branch chosen in the Pages settings B Buy a custom domain C Make the repository private D Delete the Actions tab
A missing or misnamed index.html causes most 404s.
Show answer
Complete the folder where workflow files live.
.github/ /ci.yml
GitHub looks for YAML files in .github/workflows.
Check answer Show solution
What does on: pull_request do?
A Runs the workflow whenever a pull request is opened or updated B Opens a pull request C Merges the pull request D Closes stale pull requests
on lists the triggering events.
Show answer
What's the difference between uses and run?
A They're the same B run is for Windows only C uses runs a ready-made action; run executes a shell command D uses is for secrets
Both are kinds of steps.
Show answer
A matrix lists 3 Node versions and 2 operating systems. How many jobs run?
A 2 B 3 C 5 D 6
Every combination runs: 3 times 2.
Show answer
How should a workflow use an API key?
A Write it in the YAML file B Commit it in a .env file C Print it in the logs D Store it as a repository secret and reference it with ${{ secrets.NAME }}
Secrets are encrypted and hidden in logs.
Show answer
Complete the command that creates a release with automatically written notes.
gh release create v1. 0.0 --
--generate-notes lists the merged pull requests since the last release.
Check answer Show solution
Version 2.3.4 gets a bug fix only. What's the next version?
A 3.0.0 B 2.3.5 C 2.4.0 D 2.3.4.1
Bug fixes increase PATCH.
Show answer
Version 2.3.4 removes a function that people relied on. What's the next version?
A 3.0.0 B 2.4.0 C 2.3.5 D 2.4.4
Breaking changes increase MAJOR and reset the others to 0.
Show answer
What does a pre-release mean?
A The release is deleted B A release without a tag C A test version that isn't marked as the latest stable release D A private release
Use it for betas and release candidates.
Show answer
What does on: push: tags: ["v*"] do in a workflow?
A Runs on every push to any branch B Creates a tag C Deletes old tags D Runs when a tag beginning with v is pushed
Pushing v1.3.0 would start the release workflow.
Show answer
Complete the CODEOWNERS line so the docs team owns the docs folder.
/docs/ @acme/
Teams are written as @organization/team-name.
Check answer Show solution
Why use an organization instead of a personal account for a company's code?
A Organizations are faster B Personal accounts can't have private repositories C Repositories belong to the group, with shared members, teams and settings, not to one person D Organizations don't need Git
The code stays safe when people come and go.
Show answer
Which repository role lets someone push branches and merge pull requests?
A Read B Triage C Write D None of them
Maintain and Admin can too, with extra settings access.
Show answer
What is an outside collaborator?
A An organization owner B A bot C A former member D Someone with access to specific repositories who isn't a member of the organization
Useful for contractors and guests.
Show answer
What advantage do organization rulesets have over per-repository branch protection?
A They're stricter B They replace pull requests C One rule can protect many repositories, including new ones, consistently D They don't need status checks
Consistency without editing every repository.
Show answer
Complete the name of the file that tells people how to report vulnerabilities.
.md
GitHub links SECURITY.md from the repository's Security tab.
Check answer Show solution
Which feature blocks a push that contains a secret?
A Dependabot B GitHub Pages C Push protection D Discussions
It stops the secret before it reaches GitHub.
Show answer
What do branch protection rules let you require?
A A licence file B A minimum number of stars C Private visibility D Pull requests, approvals and passing status checks before merging
They keep main reviewed and working.
Show answer
Which role can manage issues and pull requests but not push code?
A Read B Write C Triage D Admin
Triage suits people who organise work without changing code.
Show answer
An API key was pushed to a public repository an hour ago. What should you do first?
A Revoke or rotate the key at the service that issued it B Delete the file in a new commit C Make the repository private D Rename the repository
The old value remains in history and may already be copied.
Show answer
Complete the path of the dev container configuration file.
.devcontainer/
Codespaces and the Dev Containers extension read this file.
Check answer Show solution
A A Git branch B A private gist C A type of GitHub Action D A cloud development environment created from a repository and opened in VS Code
It runs on a virtual machine with the project's tools ready.
Show answer
Which devcontainer.json setting runs npm install after the container is created?
A forwardPorts B postCreateCommand C features D image
It runs once when the codespace is first created.
Show answer
What happens to a codespace you stop?
A Your files are deleted B It's converted to a gist C It keeps your files but stops using compute time D It keeps running in the background
Delete it when you don't need it at all.
Show answer
How should an API key be made available inside a codespace?
A As a Codespaces secret, which appears as an environment variable B In devcontainer.json C In a committed .env file D In the README
Secrets never belong in the repository.
Show answer
Complete the command that signs GitHub CLI in to your account.
gh auth
gh auth login signs in through the browser.
Check answer Show solution
Which command opens a pull request using your commit messages?
A gh pr open B gh push --pr C git pr create D gh pr create --fill
--fill takes the title and body from your commits.
Show answer
What does gh pr checkout 42 do?
A Merges PR 42 B Fetches PR 42's branch and switches to it C Closes PR 42 D Opens PR 42 in the browser
Useful for testing a PR locally.
Show answer
Which command follows a running Actions workflow until it finishes?
A gh run watch B gh run list C gh workflow enable D gh actions follow
It updates live in the terminal.
Show answer
How can you call a GitHub API endpoint that has no dedicated gh command?
A You can't B Use curl with your password C gh api <endpoint> D gh request --raw
gh api adds your authentication automatically.
Show answer
In the main ownership file, which teams own docs/security/access.md?
A Only @demo-org/maintainers B @demo-org/security and @demo-org/docs C Every team named anywhere in CODEOWNERS
The final matching security rule lists the two owners together.
Show answer
Which result exposes the version disagreement in the compatibility exercise?
A A alone: true B B alone: true C combined: false
Only the combined state pairs the updated produced format with the old accepted format.
Show answer
Which conversion gives the practice program's raw false text boolean meaning?
A JSON.parse(raw) followed by a type check B Boolean(raw) alone C Appending another character to raw
Parsing the JSON literal produces false; a nonempty string remains truthy when tested only for presence.
Show answer
With the practice caller's target set to tests, what should its show job print?
A received: docs checked B received: tests checked C The shared workflow's private token
The validated target is returned through the declared result output.
Show answer
In the practice program, why is changed input: false printed?
A Every SHA-256 result is an empty string B Artifact names automatically overwrite dependency versions C The different dependency content produces a different exact cache key
The digest changes when the serialized dependency input changes.
Show answer
Why can the modeled label job not publish a package?
A Its explicit allowlist contains issues:write but not packages:write B Every write capability includes every other write capability C The branch name disables all Node.js programs
Capabilities are named separately; granting one does not imply unrelated publishing access.
Show answer
Why does the local policy model reject production context?
A GitHub cannot issue any environment tokens B Its subject differs from the exact staging subject C The function verified a production deployment failed
The exercise matches fabricated claim fields and requires the staging subject; it performs no deployment.
Show answer
After the practice model moves latest, what still identifies its original modeled content?
A The word latest by itself B The previously saved digest reference C The workflow display name
The saved reference contains the first digest rather than a mutable tag.
Show answer
No exercises match those filters.