All Microsoft exams
Free GH-900 practice test: 30 questions with answers
30 original questions for GitHub Foundations, drawn from every topic area. Answer each one to see whether you got it right and why. No sign-up.
- Free questions
- 30
- Full bank
- 100 questions
All 30 GH-900 questions with answers
The same questions as the test above, grouped by exam topic. Open any question to see the answer and explanation.
Git and GitHub fundamentals (6 questions)
Question 1
A developer has made changes to a file on a local branch and wants to save a snapshot of those changes in the project history. Which Git command creates the snapshot?
- Agit init
- Bgit pull
- Cgit push
- Dgit commit
Show answer and explanationHide answer
Correct answer: Dgit commit records the staged changes as a new snapshot in the local repository history. Cloning copies a remote repository, fetching downloads remote updates without merging, and init creates a new repository.
Question 2
A team member wants to start a new feature without disturbing the main branch. Which Git operation creates an isolated line of development for that work?
- ACreating a new branch from main
- BDeleting the main branch
- CPushing directly to a release asset
- DMerging main into a tag
Show answer and explanationHide answer
Correct answer: AA new branch gives an independent line of development that can be merged later after review. Deleting main, merging into a tag and uploading release assets do not isolate feature work.
Question 3
A developer copies a repository from GitHub to a laptop so they can work offline. Which action performs this copy?
- Agit clone
- Bgit merge
- Cgit push
- Dgit revert
Show answer and explanationHide answer
Correct answer: Agit clone creates a local copy of a remote repository, including its history. Push sends local commits to a remote, merge combines branches, and revert creates a commit that undoes earlier changes.
Question 4
Two developers changed the same line of a file on different branches, and Git cannot combine the changes automatically. What is this called?
- AA merge conflict that must be resolved manually
- BA tag mismatch, where a tag points to an older commit
- CA protected branch rule that blocks direct pushes to main
- DA separate copy of the team repository
Show answer and explanationHide answer
Correct answer: AWhen the same lines change differently on two branches, Git reports a merge conflict that needs a person to choose the result. A fork is a separate copy of a repository, tags name commits, and protected branch rules restrict changes.
Question 5
A contributor wants to propose changes to a project they do not have write access to. Which GitHub feature should they use?
- ARequest organization owner admin rights on the upstream repository
- BFork the repository and open a pull request from their fork
- CCommit edits straight onto the upstream repository's main branch
- DEmail a git patch file to the maintainer each time
Show answer and explanationHide answer
Correct answer: BA fork gives the contributor their own copy with write access, and a pull request proposes merging those changes into the upstream project. Admin rights are not needed, direct edits are blocked without write access, and emailed patches bypass the review workflow.
Question 6
A repository should show a short project description, licence and topics on its main page, so visitors understand it quickly. Which file usually provides the main introduction?
- Aconfig.yml under .github
- Bgitignore
- CCODEOWNERS
- DREADME.md
Show answer and explanationHide answer
Correct answer: DThe README is displayed on the repository's home page and typically introduces the project. The other files configure tooling, ignore patterns or ownership and are not the main introduction.
Collaboration and pull requests (6 questions)
Question 7
A pull request must not be merged until at least two reviewers approve it and the automated tests pass. Which GitHub feature enforces this?
- AA README file that asks reviewers to approve the pull request
- BBranch protection rules with required reviews and required status checks
- CA label named approved that reviewers add by hand after each round
- DA wiki page listing the reviewers and their approval status
Show answer and explanationHide answer
Correct answer: BBranch protection rules can require a number of approving reviews and passing status checks before merge, which enforces the policy. A README, a label or a wiki page is informational and does not block merging.
Question 8
A reviewer wants to comment on a specific line of code in a pull request, and the author needs to respond in the same thread. Which feature provides this?
- AIssues with no link to the specific code or diff
- BReleases with changelog text alone, published after merge
- CReview comments attached to lines in the pull request
- DDiscussions about unrelated topics and general project news
Show answer and explanationHide answer
Correct answer: CReview comments attach to specific lines in the diff and form threads that the author can answer. Issues without code links, release notes and general discussions are not tied to the changed lines.
Question 9
A maintainer wants to track a bug report, assign it to a developer, and link it to the pull request that fixes it. Which GitHub feature supports this?
- AGists, which store single code snippets and their revisions
- BSponsors, which manage monthly donations to developers
- CPackages, which store container images and npm modules
- DIssues, which can be assigned and referenced from pull requests
Show answer and explanationHide answer
Correct answer: DIssues track work items with assignees, and a pull request can reference or close an issue. Gists store snippets, packages host artifacts, and Sponsors manages donations, so none of them tracks bug work.
Question 10
A pull request should close an issue automatically when it is merged. Which text in the pull request description accomplishes this?
- ACloses #42 in the pull request description
- BPlease look at issue forty-two
- CIgnore issue 42 for now
- DMention issue 42 in the title only with no other text
Show answer and explanationHide answer
Correct answer: AKeywords such as Closes followed by the issue number link the pull request to the issue and close it on merge. Informal mentions or ignoring the issue do not close it automatically.
Question 11
A repository owner wants specific team members to be automatically requested as reviewers for changes to the payments folder. Which file defines this?
- ALICENSE
- BREADME.md
- Cdependabot.yml
- DCODEOWNERS
Show answer and explanationHide answer
Correct answer: DCODEOWNERS maps paths to owners, and those owners are requested for review when matching files change. Dependabot configuration, README and licence files do not assign reviewers.
Question 12
A team wants to organize its work into projects with a board showing issues and pull requests by status. Which GitHub feature should be used?
- AGists for each status, with one gist per column that lists the issues and pull requests
- BProjects, which provide boards and tables linked to issues and pull requests
- CPackages for each column, with each package tagged by board status
- DA wiki with a table of contents, linked to a separate page listing every status label
Show answer and explanationHide answer
Correct answer: BProjects offer boards and tables that track issues and pull requests by status and custom fields. Gists, packages and a wiki index do not provide that workflow view.
Security and compliance (6 questions)
Question 13
A developer accidentally committed an API token to a repository. What should happen first?
- APost the full token value in a new issue so that the whole team and every reviewer can see it and track it
- BLeave the token as it is because the repository is private and access is limited to trusted collaborators
- CRevoke the token and issue a new one, then remove the secret from the history if needed
- DDelete the latest commit with git reset --hard HEAD~1 and force push the branch, leaving the secret
Show answer and explanationHide answer
Correct answer: CA committed secret must be treated as compromised, so revoking and rotating it comes first, and history cleanup is secondary. Assuming privacy, deleting only the last commit and posting the token all leave the secret exposed.
Question 14
Which two features help protect a repository from vulnerable dependencies? (Choose two.)
- ATurning off the dependency graph to reduce noise
- BPublishing lock files publicly without any review
- CDependabot alerts that report known vulnerabilities in dependencies
- DIgnoring alerts until the next release
- EDependabot security updates that open pull requests with fixes
Show answer and explanationHide answer
Correct answer: C, EDependabot alerts flag known vulnerable dependencies and security updates propose fixes as pull requests. Disabling the dependency graph removes visibility, and ignoring alerts or publishing lock files without review increases exposure.
Question 15
A repository contains a secret that must be available to a deployment workflow but must never appear in logs or code. Which GitHub feature should store it?
- AA plain text file in the repository that holds the value unencrypted and is tracked
- BA comment in the workflow YAML file that records the secret value so it can be read by reviewers
- CAn issue comment on a public thread that shows the secret value in plain text
- DEncrypted secrets in the repository or environment settings, referenced by the workflow
Show answer and explanationHide answer
Correct answer: DEncrypted secrets are stored in settings and injected into workflows at run time, and their values are masked in logs. Plain text files, YAML comments and issue comments expose the value.
Question 16
A security team wants to be notified when a code scanning tool finds a new potential vulnerability in the repository. Which GitHub feature provides this?
- ACode scanning alerts
- BRepository star counts
- CRelease notes and tags
- DWiki page updates
Show answer and explanationHide answer
Correct answer: ACode scanning produces alerts for potential vulnerabilities, which can be triaged and tracked. Wiki edits, stars and release notes do not report security findings.
Question 17
A developer wants to enable two-factor authentication for their account to protect against password theft. Which option is the most secure method among the choices?
- AA passkey or security key
- BA password written on a sticky note
- CSharing one account between team members
- DTurning off sign-in alerts
Show answer and explanationHide answer
Correct answer: APasskeys and security keys are phishing-resistant second factors, which provide the strongest protection. Written passwords, shared accounts and disabled alerts weaken security.
Question 18
An organization wants all members to use two-factor authentication to access its repositories. Where should this be enforced?
- AIn the organization's security settings as a requirement
- BIn the README file at the root of each repository
- CIn each member's personal account profile under the security tab
- DIn a wiki page asking members to enable it manually
Show answer and explanationHide answer
Correct answer: AOrganization settings can require two-factor authentication for all members, which enforces the policy centrally. Personal profiles, READMEs and wiki requests depend on individual choice.
GitHub Copilot and automation (6 questions)
Question 19
A developer wants AI-assisted code suggestions and chat inside the editor while writing code. Which GitHub product provides this?
- AGitHub Sponsors
- BGitHub Copilot
- CGitHub Gists
- DGitHub Pages
Show answer and explanationHide answer
Correct answer: BGitHub Copilot provides AI-assisted code suggestions and chat in supported editors. GitHub Pages hosts websites, Sponsors manages funding, and Gists store snippets.
Question 20
Which two statements about GitHub Actions workflows are correct? (Choose two.)
- AWorkflows are defined in YAML files stored in the .github/workflows folder
- BWorkflows run only when someone manually clicks merge
- CWorkflows work only for public repositories
- DWorkflows cannot run tests
- EWorkflows can be triggered by events such as a push or a pull request
Show answer and explanationHide answer
Correct answer: A, EWorkflows are YAML files in .github/workflows and are triggered by events such as pushes and pull requests. They are not limited to manual merges or public repositories, and they are commonly used to run tests.
Question 21
A team wants a workflow to run whenever a new issue is opened with the bug label, and to add a triage comment automatically. Which mechanism implements this?
- AA manual reminder posted each Monday for someone to review open bug reports
- BA release created for each new issue, tagged with the issue number and published to the changelog
- CA GitHub Actions workflow triggered by the issues event with a condition on the label
- DA fork of the repository created for each bug, with a separate copy of the full commit history
Show answer and explanationHide answer
Correct answer: CA workflow triggered by the issues event, with a condition on the label, automates the triage comment. Manual reminders, releases per issue and forks per bug do not automate triage.
Question 22
A repository needs a container image built and published whenever a release tag is created. Which automation fits best?
- AA manual upload of the image from a developer's laptop with a local build
- BA README update that describes the image and its tags for consumers
- CA label on the release that marks it for manual publishing
- DA GitHub Actions workflow triggered by the release or tag event
Show answer and explanationHide answer
Correct answer: DA workflow triggered by the release or tag event builds and publishes the image automatically and consistently. Manual uploads, README changes and labels do not publish images.
Question 23
A developer wants to reuse the same set of workflow steps across several repositories in an organization. Which GitHub Actions feature supports this?
- ACopying the YAML by hand into each repository without later updates
- BRunning the steps on one developer's laptop with local secrets and no shared runner
- CStoring the steps in an email thread shared with the maintainers
- DReusable workflows or composite actions called from multiple repositories
Show answer and explanationHide answer
Correct answer: DReusable workflows and composite actions let several repositories call shared logic, which keeps the steps consistent and easy to update. Manual copies drift, email is not a workflow mechanism, and laptop-only runs do not serve the organization.
Question 24
A team wants Dependabot to keep its GitHub Actions versions up to date by opening pull requests. Which file configures this?
- A.github/dependabot.yml
- B.github/CODEOWNERS.txt
- Cdocs/contributing/README.md
- Dvendor/licenses/LICENSE.md
Show answer and explanationHide answer
Correct answer: AThe dependabot.yml configuration file defines which package ecosystems, including GitHub Actions, are checked and how often updates are proposed. The other files do not configure Dependabot.
Community and organizations (6 questions)
Question 25
A company wants to group its repositories and manage access for several teams from one place. Which GitHub structure should it use?
- AAn organization with teams and repository permissions
- BA single shared password for each department's repositories
- CA personal account for each developer, holding repositories
- DA public gist per team, each listing its members and their roles
Show answer and explanationHide answer
Correct answer: AOrganizations group repositories and manage teams and permissions centrally, which suits a company. Individual accounts, shared passwords and gists do not provide centralized team management.
Question 26
A contributor is new to an open-source project and wants to know how to behave and how to report problems. Which community file should the project provide?
- AA LICENSE file with no other text about reuse
- BA .gitignore file listing build output and logs
- CCODE_OF_CONDUCT.md and CONTRIBUTING.md
- DA release tag named latest on the newest build
Show answer and explanationHide answer
Correct answer: CCODE_OF_CONDUCT.md sets behaviour expectations and CONTRIBUTING.md explains how to contribute and report issues. A licence, an ignore file and a tag do not provide that guidance.
Question 27
A maintainer wants to limit who can comment on a public issue after it becomes spam. Which action is appropriate?
- ADelete the entire repository
- BTurn off all notifications for the whole organization
- CRemove the README
- DLock the conversation and limit it to collaborators
Show answer and explanationHide answer
Correct answer: DLocking a conversation limits who can comment, which contains spam while keeping the record. Deleting the repository or the README and turning off organization notifications do not address the spam in that thread.
Question 28
An organization wants to assign day-to-day maintenance of a large set of repositories to a team without giving that team organization owner rights. Which approach does this?
- AMake every member of the team an organization owner with full privileges
- BShare the organization owner's password with the team through a shared vault entry for on-call sign-in access
- CGrant the team the appropriate repository role, such as maintain, on the relevant repositories
- DGive the team access to billing settings, including payment methods, invoices, tax receipts, renewal dates
Show answer and explanationHide answer
Correct answer: CRepository roles such as maintain give the team operational rights on specific repositories without organization-wide authority. Owner status, shared passwords and billing access exceed the requirement.
Question 29
A project wants to accept financial support from the community to fund maintenance. Which GitHub feature provides this?
- AGitHub Issues templates
- BGitHub Sponsors
- CGitHub Pull request labels
- DGitHub Actions cache
Show answer and explanationHide answer
Correct answer: BGitHub Sponsors lets maintainers receive funding from the community. Issue templates, pull request labels and the Actions cache do not provide funding.
Question 30
Which two items help new contributors start work on a repository quickly? (Choose two.)
- ANo instructions, so contributors explore on their own
- BA clear README with setup and test instructions
- CIssue templates that ask for steps to reproduce a bug
- DClosing all open issues so the list looks clean
- ELeaving the default branch unnamed and unprotected
Show answer and explanationHide answer
Correct answer: B, CSetup instructions in the README and structured issue templates reduce guesswork and help contributors report useful information. Missing instructions, closing all issues and an unnamed default branch make contributions harder.