First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.
Continue in the practice tool above to load more questions, 50 at a time.
Question 1Introduction to Git and GitHub
What is the main purpose of a version control system?
- Compiling source code into runnable binaries and packaging them for release
- Backing up a project to cloud storage on a fixed schedule
- Automatically formatting source code to match a team style guide
- Tracking changes to files so earlier versions can be restored Correct answer.
Explanation
A version control system records the history of a project so you can compare, revert, and branch over time. Each saved change becomes part of a traceable history rather than a single overwritten copy.
Question 2Introduction to Git and GitHub
Which statement correctly distinguishes Git from GitHub?
- Git is a cloud hosting service; GitHub is the local client
- Git and GitHub are two names for the same product
- GitHub is the command-line program that Git hosting servers use to store commits
- Git is a distributed version control system; GitHub hosts Git repositories Correct answer.
Explanation
Git is the version control software that runs locally and manages commits and history. GitHub is a separate online platform that stores Git repositories and adds collaboration features such as pull requests and issues.
Question 3Introduction to Git and GitHub
In a distributed version control system like Git, what does a full clone of a repository contain?
- Only the most recent version of each file
- A link to the server that must be online to view history
- The project's complete commit history, not just the latest files Correct answer.
- Only the commits created after the clone was made
Explanation
Because Git is distributed, cloning copies the entire repository including all commits and branches that were fetched. This lets you view history, commit, and branch while offline, then sync later.
Question 4Introduction to Git and GitHub
What is a commit in Git?
- A saved copy of the entire repository stored outside the project folder
- A request asking maintainers to review your changes
- A temporary file Git uses while merging branches
- A snapshot of staged changes with an author, message, and ID Correct answer.
Explanation
A commit records the content of the staging area as a snapshot along with metadata such as author, timestamp, message, and a unique hash. Commits form the chain of history you can inspect and revert to.
Question 5Introduction to Git and GitHub
What is a Git repository?
- A list of contributors shown on a GitHub profile
- A hosted backup of a folder that GitHub creates automatically
- A folder tracked by Git whose hidden .git directory stores its history Correct answer.
- A single file that Git uses to record the last commit
Explanation
A repository is the project folder plus the .git directory, which holds commits, branches, and configuration. Everything needed to reconstruct the project's history lives inside that .git directory.
Question 6Introduction to Git and GitHub
What is the purpose of a README file in a GitHub repository?
- It describes the project and how to use it, and is shown on the repository page Correct answer.
- It lists the branches available on the remote
- It configures which files Git should ignore
- It stores the license terms for the project
Explanation
GitHub automatically renders a README on the repository's main page, making it the standard place to explain what the project does, how to install it, and how to contribute. It is documentation, not configuration.
Question 7Introduction to Git and GitHub
What does forking a repository on GitHub do?
- Creates a copy under your account, linked to the original Correct answer.
- Downloads the repository to your computer as a compressed zip archive
- Creates a branch inside the original repository
- Deletes the original repository from the owner's account
Explanation
A fork is a server-side copy of someone else's repository placed in your own GitHub account, keeping a link to the original so you can propose changes back. It is independent of your local machine until you clone it.
Question 8Introduction to Git and GitHub
What is the role of a .gitignore file?
- It removes files from the repository's history permanently
- It tells Git which files and patterns to leave out of version control Correct answer.
- It encrypts files so other users cannot read them
- It lists the commits that should not be pushed
Explanation
A .gitignore file contains patterns matching files Git should treat as untracked and skip when staging. It is typically used for build output, dependencies, and local environment files.
Question 9Introduction to Git and GitHub
Which description best fits the Git staging area, also called the index?
- A remote server where commits are pushed
- A permanent archive of every commit ever made
- A holding area where changes are collected for the next commit Correct answer.
- A folder where deleted files are kept for recovery
Explanation
Staging lets you choose exactly which changes go into the next commit, so a working tree with several edits can be committed in separate logical groups. Commit records what is staged, not everything that changed on disk.
Question 10Introduction to Git and GitHub
After running git clone with a repository URL, what does Git set up automatically?
- A local copy with a remote named origin and the default branch checked out Correct answer.
- A new empty repository with no connection to the source
- A bare repository containing no working files
- A fork of the repository on GitHub plus a read-only copy locally
Explanation
Cloning copies the history, creates a working tree, records the source URL as the remote origin, and checks out the default branch. A fork must be created separately on GitHub.
Question 11Introduction to Git and GitHub
What is a pull request on GitHub?
- An automated test that runs every time code is pushed
- A command that downloads new commits from a remote repository into your local one
- A proposal to merge one branch into another, open for review and discussion Correct answer.
- A request for permission to create a new repository in an organization
Explanation
A pull request proposes integrating commits from a source branch into a target branch and provides a place to review the diff, comment, and run checks. It is a collaboration feature of GitHub, not a Git command.
Question 12Introduction to Git and GitHub
What is a branch in Git?
- A tag that marks a release version
- A saved list of commands to replay on a new machine
- A duplicate copy of the repository stored on a server
- A movable pointer to a commit that lets work proceed independently Correct answer.
Explanation
A branch is simply a named reference that advances as new commits are made, allowing parallel lines of work inside one repository. Switching branches changes which commit you are building on without copying the whole project.
Question 13Introduction to Git and GitHub
Which command associates a local repository with a remote repository named origin?
- git branch origin <url>
- git remote add origin <url> Correct answer.
- git clone origin <url>
- git push origin <url>
Explanation
The git remote add command registers a new remote with a chosen name and URL in the local configuration. After that, commands such as git push and git fetch can refer to it by name.
Question 14Introduction to Git and GitHub
How does git fetch differ from git pull?
- fetch works only with forks; pull works only with the origin remote
- fetch uploads local commits; pull downloads remote commits
- fetch downloads changes without integrating them; pull downloads and then merges Correct answer.
- fetch merges remote changes into the current branch, while pull only downloads them
Explanation
Fetch updates remote-tracking references so you can inspect incoming work before combining it with your branch. Pull performs a fetch and then integrates the changes, typically with a merge.
Question 15Introduction to Git and GitHub
In GitHub Flow, what typically happens once work on a feature branch is finished?
- The repository is archived until the next release
- A pull request is opened for review, then merged into the default branch Correct answer.
- The branch is pushed directly to main and deployed without review
- The branch is deleted and the work is redone on a fork
Explanation
GitHub Flow centers on short-lived branches and pull requests: changes are proposed, reviewed, and checked before merging into the always-deployable default branch. This keeps the main line stable while enabling frequent releases.
Question 16Introduction to Git and GitHub
What are GitHub issues mainly used for?
- Running continuous integration workflows
- Storing large binary files outside of Git
- Granting collaborators write access to a repository
- Tracking bugs, tasks, and feature requests with comments and labels Correct answer.
Explanation
Issues provide a lightweight tracker where maintainers and contributors discuss problems, plan work, and organize items with labels, assignees, and milestones. They are not storage or permission mechanisms.
Question 17Introduction to Git and GitHub
What does the long hexadecimal string that identifies a Git commit represent?
- A hash of the commit content and metadata, making it unique Correct answer.
- The numeric identifier of the GitHub user account that made the commit
- An encryption key used to sign the repository
- The line number in the file where the change was introduced
Explanation
Git computes a cryptographic hash over the commit's tree, parents, author, and message, which uniquely identifies that commit and links history together. Because the value derives from the content, any change produces a different identifier.
Question 18Introduction to Git and GitHub
In GitHub-flavored Markdown, which syntax creates a top-level, largest heading?
- **Heading**
- `Heading`
- # Heading Correct answer.
- *Heading*
Explanation
A single hash followed by a space marks a level-one heading in Markdown. Additional hashes create progressively smaller heading levels.
Question 19Introduction to Git and GitHub
What does including an open-source license file in a repository do?
- States the terms under which others may use, modify, and share the code Correct answer.
- Guarantees the project will be accepted by GitHub
- Transfers copyright ownership of the code from the author to GitHub
- Makes the repository private to contributors only
Explanation
A license grants permissions and sets conditions for reuse, modification, and redistribution of the code. Without one, default copyright rules apply and others have no clear right to reuse the work.
Question 20Introduction to Git and GitHub
How does a GitHub organization differ from a personal account?
- An organization cannot own repositories
- Only GitHub staff can create organizations
- An organization is a shared account where multiple people own repositories through teams Correct answer.
- An organization is simply a single user account that has no shared settings or billing of its own
Explanation
Organizations exist so groups can own repositories together, with roles, teams, and centralized billing. Personal accounts represent one person, while organizations represent a collective that manages shared resources.
Question 21Introduction to Git and GitHub
Which statement best describes how Git stores project data?
- It stores data in a relational database that is managed by GitHub
- It stores only the differences between files as plain text patch files
- It stores a separate compressed copy of every file at every commit, regardless of whether the content changed
- Snapshots are stored as content-addressed objects, so identical content is shared Correct answer.
Explanation
Git records snapshots of the tree and stores file contents in objects keyed by a hash of their content. Unchanged files reuse the same object across commits, which keeps the repository compact without losing snapshot semantics.
Question 22Introduction to Git and GitHub
In Git, what does HEAD refer to?
- A reference to the commit or branch that is currently checked out Correct answer.
- The .git directory that holds repository metadata
- The very first commit made in the repository
- The remote-tracking branch that mirrors the server
Explanation
HEAD is a pointer that indicates your current position in history, normally naming the checked-out branch and thereby its latest commit. New commits advance the branch that HEAD points to.
Question 23Introduction to Git and GitHub
What happens when two branches change the same lines of a file and you merge them?
- Git reports a merge conflict that you must resolve manually Correct answer.
- Git keeps both versions and marks the file as read-only
- Git automatically reverts both commits to their previous state
- Git silently prefers the changes from the branch that was merged second
Explanation
When overlapping lines cannot be reconciled automatically, Git pauses the merge and marks the conflicting regions in the file. You edit the file to the desired result, stage it, and complete the merge with a commit.
Question 24Introduction to Git and GitHub
Why is force-pushing a rewritten history to a shared branch considered risky?
- It permanently deletes the remote repository
- It converts the repository from public to private
- It replaces commits others have built on, which can break their branches Correct answer.
- It is rejected by Git because force pushing is not an available option in Git
Explanation
A force push makes the remote branch point at a rewritten history, discarding commits that others may have already fetched and built upon. Collaborators then face diverged histories and must manually reconcile their work.
Question 25Introduction to Git and GitHub
What does choosing "Squash and merge" for a pull request do?
- Combines all commits from the pull request into a single commit on the base branch Correct answer.
- Creates a merge commit that keeps every individual commit from the pull request on the base branch
- Closes the pull request without applying any of its changes
- Merges only the first commit from the pull request into the base branch
Explanation
Squash merging condenses the branch's commits into one new commit applied to the base branch, giving a tidy linear history. The individual commits remain visible only in the pull request record.
Question 26Introduction to Git and GitHub
Which statement describes the type of version control system Git is?
- A centralized system that needs a server for each commit
- A distributed system where every clone holds full history Correct answer.
- A backup tool that archives directories on a fixed schedule
- A file-sync service that keeps only the latest version
Explanation
Git is distributed: cloning a repository copies the entire commit history, so most operations run locally without contacting a server. Centralized systems keep history in one place and require server access for many operations.
Question 27Introduction to Git and GitHub
What is stored in the .git directory of a project?
- The repository's objects, refs, and configuration data Correct answer.
- Only the ignore rules and license text for the project
- A copy of the files as they looked before the last commit
- Temporary files created while editing source code
Explanation
The .git directory is the repository itself, holding the object database of commits and files, the references such as branches and tags, and local configuration. Deleting it removes the project's version history even though the working files remain.
Question 28Introduction to Git and GitHub
Which command creates a new, empty Git repository in the current directory?
- git start
- git create
- git init Correct answer.
- git open
Explanation
git init initializes a repository by creating the .git directory in the current folder, after which files can be tracked. Commands such as git start, git create, and git open do not exist in Git.
Question 29Introduction to Git and GitHub
You run git config --global user.name "Ada". Where is the value recorded?
- In a per-user config file for the current account Correct answer.
- In the message text of the next commit you create
- In a machine-wide file that affects all user accounts
- In the .git/config file of the current repository
Explanation
The --global flag writes to the user-level configuration file for the signed-in account, typically in the home directory, so the setting applies to every repository that account uses. Repository-specific and system-wide settings use different scopes.
Question 30Introduction to Git and GitHub
Which command reports which files are staged, modified, or untracked in the working directory?
- git status Correct answer.
- git show
- git blame
- git log
Explanation
git status compares the working directory and the index with the last commit and summarizes staged, modified, and untracked paths. The other commands display commit history or per-line attribution rather than the current state of files.
Question 31Introduction to Git and GitHub
You edited a tracked file but have not staged it. Which command displays those unstaged changes?
- git status --short
- git diff Correct answer.
- git show HEAD
- git log -1
Explanation
With no arguments, git diff compares the working tree against the index and prints the unstaged line changes. git status lists which files differ but does not show the changed lines themselves.
Question 32Introduction to Git and GitHub
Which command displays the ordered history of commits on the current branch?
- git history
- git log Correct answer.
- git tag
- git show
Explanation
git log walks the commit graph from the current branch tip and lists commits with their metadata and messages. git history is not a Git command, and the other options deal with a single object or with tags.
Question 33Introduction to Git and GitHub
Which command lists the remote repositories configured for a local repository, including their URLs?
- git branch -a
- git remote -v Correct answer.
- git config remotes
- git push --list
Explanation
git remote -v prints each configured remote name with its fetch and push URLs. git branch -a lists branches, including remote-tracking branches, but does not show remote URLs.
Question 34Introduction to Git and GitHub
How does GitHub relate to Git?
- A hosting service for Git repositories with collaboration tools Correct answer.
- A newer version control system that replaces Git entirely
- A command-line program included in the Git installer
- The company that owns the Git project and its trademark
Explanation
Git is the version control system that records history, while GitHub is a platform that hosts Git repositories and adds features such as pull requests, issues, and access control. Git works fully without GitHub.
Question 35Introduction to Git and GitHub
A file was added with git add, and you now want to unstage it while keeping your edits in the working directory. Which command does this?
- git revert <file>
- git commit --undo <file>
- git restore --staged <file> Correct answer.
- git clean -f <file>
Explanation
git restore --staged removes the file's changes from the index, so the next commit will not include them, while the working copy stays untouched. Removing changes from the index does not delete the file content.
Question 36Introduction to Git and GitHub
After staging changes, which command records them as a new commit with the message "Fix login bug"?
- git add -m "Fix login bug"
- git push -m "Fix login bug"
- git commit -m "Fix login bug" Correct answer.
- git tag -m "Fix login bug"
Explanation
git commit writes the staged snapshot to history, and the -m flag supplies the commit message inline. Staging must already have happened, because commits capture the index, not unstaged working-tree edits.
Question 37Introduction to Git and GitHub
Why do commits carry a message?
- To name the branch that the commit belongs to
- To describe why the change was made for later readers Correct answer.
- To encrypt the commit contents while in transit
- To trigger the repository's license validation
Explanation
A commit message records the intent behind a change so teammates and future maintainers can understand history without reading every diff. Branch names and transport security are handled by Git itself, not by the message.
Question 38Introduction to Git and GitHub
A local repository has commits but no remote configured. Which sequence publishes it to an empty GitHub repository at https://github.com/ada/project.git?
- git init https://github.com/ada/project.git, then git fetch origin main
- git clone https://github.com/ada/project.git, then git commit -m "initial"
- git push origin main, then git remote add origin https://github.com/ada/project.git
- git remote add origin https://github.com/ada/project.git, then git push -u origin main Correct answer.
Explanation
The remote must be registered before any push can target it, and the -u flag on the first push records the upstream so later commands can omit the remote and branch. Pushing first fails because no remote named origin exists yet.
Question 39Introduction to Git and GitHub
What does git commit --amend do to the most recent commit?
- Appends a new empty commit on top of the current branch
- Publishes the last commit directly to the default remote
- Replaces the last commit with an updated snapshot Correct answer.
- Merges the last two commits into a single new commit
Explanation
Amending rewrites the most recent commit, letting you fold in newly staged changes or edit its message, which produces a new commit hash. Because the hash changes, amending commits that others already fetched requires care.
Question 40Introduction to Git and GitHub
Which command shows each local branch together with the remote branch it tracks?
- git log --all
- git branch -vv Correct answer.
- git reflog
- git tag -l
Explanation
The -vv flags make git branch print each branch with its upstream and how far it has diverged, which reveals tracking relationships set by push -u or clone. The other commands list commit movements, commits across refs, or tags.
Question 41Working with GitHub Repositories
When you create a new repository in the GitHub web interface, which option adds content that is rendered directly on the repository's landing page?
- Add a .gitignore file
- Add repository topics
- Add a README file Correct answer.
- Choose a license
Explanation
A README file is rendered on the repository's landing page, which makes it the natural place for a project description, setup steps and usage notes. The other choices create files or metadata that are not displayed as the main body of the repository page.
Question 42Working with GitHub Repositories
Which command creates a local working copy of a remote repository along with its full commit history?
- git fetch <url>
- git clone <url> Correct answer.
- git init
- git remote add origin <url>
Explanation
Cloning downloads the repository's objects, sets up a remote named origin by default, and checks out the default branch into a new working directory. The other commands either start an empty repository or only partially wire up a connection to a remote.
Question 43Working with GitHub Repositories
What is the purpose of a .gitignore file in a repository?
- It tells Git which untracked files and folders to skip. Correct answer.
- It lists files that Git should commit even when they are unchanged.
- It stores the default commit message Git uses for each commit.
- It defines which collaborators may push to the repository.
Explanation
Git consults the patterns in .gitignore when deciding which untracked paths to leave out of the index, which keeps build output, logs and local secrets out of commits. The file affects neither commit messages nor who has access to the repository.
Question 44Working with GitHub Repositories
What does forking a repository do?
- It copies the original repository's issues and pull requests.
- It grants you write access to the original repository.
- It creates a copy of the repository under your own account. Correct answer.
- It creates a new branch inside the original repository.
Explanation
A fork is a new repository owned by your account that shares commit history with the original, which is then called the upstream repository. It is the standard way to propose changes to a project where you do not have write access.
Question 45Working with GitHub Repositories
What are GitHub Issues primarily used for in a repository?
- Tracking bugs, tasks and feature requests. Correct answer.
- Documenting the license terms of the project.
- Running automated tests on every push.
- Storing large binary files next to the source code.
Explanation
Issues provide a lightweight tracker for bugs, to-dos, and feature ideas, with labels, assignees and milestones for organisation. Automated testing and licensing are handled by other parts of GitHub.
Question 46Working with GitHub Repositories
Which statement describes what starring a repository does?
- It subscribes you to notifications for all repository activity.
- It copies the repository into your own account.
- It gives you permission to merge pull requests.
- It bookmarks the repository to your starred list. Correct answer.
Explanation
Starring adds a repository to your personal starred list so you can find it again, and it signals interest to maintainers. It changes no permissions and does not create a copy of the project.
Question 47Working with GitHub Repositories
On a repository's main page, what does the Code button provide?
- The full text of the repository's license.
- The clone URLs for HTTPS, SSH and the GitHub CLI. Correct answer.
- The repository's published release notes.
- The list of open issues in the repository.
Explanation
The Code button exposes the addresses you can pass to git clone, including HTTPS, SSH and GitHub CLI forms, plus a download of the source as a ZIP archive. The other items live on their own tabs or in the About sidebar.
Question 48Working with GitHub Repositories
What does setting a repository's visibility to public mean?
- Only organization owners can see the repository.
- Anyone on the internet can see the repository. Correct answer.
- Anyone can see it, but only the creator can clone it.
- It is visible only to members of your organization.
Explanation
A public repository is readable by everyone, and anyone may clone or fork it, while the ability to push still depends on granted roles. Visibility and permission to modify are separate controls.
Question 49Working with GitHub Repositories
Which file at the root of a repository states the terms under which others may use, modify and redistribute the code?
- README.md
- CONTRIBUTING.md
- CODEOWNERS
- LICENSE Correct answer.
Explanation
A LICENSE file carries the legal text of the chosen license and tells GitHub which license badge to display. Its presence clarifies what others are permitted to do with the code.
Question 50Working with GitHub Repositories
What is the effect of marking a repository as a template?
- It makes the repository read-only for everyone except organization owners.
- It lets others generate new repositories from its files and structure. Correct answer.
- It requires every pull request to be approved by an administrator.
- It automatically creates a fork for every user who views the repository.
Explanation
A template repository appears under a Use this template button, and people who use it get a fresh repository containing the same files and directory layout with a new history. It is a starting point rather than a live copy.