GitHub Foundations (GH-900) · 12% practice allocation

GitHub GH-900: Work with GitHub Repositories Practice Questions

5 free sample questions from the Work with GitHub Repositories domain, with answers and explanations. The full GH-900 bank has 150 questions across 7 domains. Questions are scenario-based and written from the official GitHub exam guide.

1.

A team is setting up a new GitHub repository for an internal company project. The project must be visible to all employees within the organization's GitHub Enterprise instance, but must NOT be accessible to the general public or external users. Which repository visibility setting should they choose?

  • A. Protected
  • B. Public
  • C. Private
  • D. Internal✓ Correct
Explanation

The 'Internal' visibility setting is available on GitHub Enterprise Cloud/Server and makes the repository visible to all authenticated members of the enterprise, while remaining hidden from the public internet and external users. 'Public' would expose the repository to anyone on the internet, which violates the requirement. 'Private' would restrict access to only explicitly invited collaborators, which is more restrictive than needed and would exclude all other employees by default. 'Protected' is not a valid repository visibility setting in GitHub.

2.

A team lead wants to ensure that no one can push directly to the 'main' branch of their repository, and that all changes must go through a pull request with at least one approving review. Where in GitHub should they configure this?

  • A. Repository Settings → Actions → General → Workflow permissions
  • B. Repository Settings → Branches → Branch protection rules✓ Correct
  • C. Repository Settings → Collaborators and teams → Role assignments
  • D. Repository Settings → Environments → Protection rules
Explanation

Branch protection rules, found under Repository Settings → Branches, allow administrators to require pull request reviews before merging, prevent direct pushes to protected branches, and enforce other policies like status checks. Action workflow permissions control what GitHub Actions can do, not human push access. Collaborator role assignments control what permissions a user has globally on the repo, but they do not enforce the pull-request-only workflow for a specific branch. Environment protection rules are used to gate deployment workflows to specific environments, not to protect branches from direct commits.

3.

A developer has just released version 2.0.0 of their library. They want to create a Git tag that stores extra metadata such as the tagger's name, email, date, and a tagging message. Which command creates this type of tag?

  • A. git tag v2.0.0
  • B. git tag -s v2.0.0
  • C. git tag --light v2.0.0 -m "Release version 2.0.0"
  • D. git tag -a v2.0.0 -m "Release version 2.0.0"✓ Correct
Explanation

'git tag -a' creates an annotated tag, which is a full Git object containing the tagger's name, email, date, and a message — suitable for public release milestones. 'git tag v2.0.0' (with no flags) creates a lightweight tag, which is simply a pointer to a commit with no extra metadata. '--light' is not a valid git tag flag. 'git tag -s' creates a GPG-signed tag (which is a type of annotated tag), but the question specifically mentions extra metadata including a tagging message, and the most direct/standard command for that is '-a'; additionally, '-s' requires a configured GPG key, making it a more specific and less universally applicable answer.

4.

When following semantic versioning (SemVer), a library maintainer releases a new version that introduces new functionality in a backward-compatible manner. No existing APIs are broken or removed. Which version number change is correct if the current version is 1.4.2?

  • A. 1.4.2-beta.1
  • B. 1.5.0✓ Correct
  • C. 1.4.3
  • D. 2.0.0
Explanation

Under Semantic Versioning, the MINOR version is incremented when new, backward-compatible functionality is added — resulting in 1.5.0 (the patch number resets to 0). The MAJOR version (2.0.0) is incremented only for breaking, backward-incompatible changes. The PATCH version (1.4.3) is incremented only for backward-compatible bug fixes, not new features. A pre-release label like '1.4.2-beta.1' denotes an unstable pre-release version, not a stable feature release.

5.

A developer realizes they made a typo in their most recent commit message on a local branch that has NOT yet been pushed to GitHub. Which command allows them to correct the commit message without creating a new commit?

  • A. git revert HEAD
  • B. git commit --fixup HEAD
  • C. git reset --soft HEAD~1
  • D. git commit --amend✓ Correct
Explanation

'git commit --amend' rewrites the most recent commit, allowing the developer to edit its message (and optionally its content) without adding a new commit to the history — ideal for fixing a typo before pushing. 'git revert HEAD' creates a brand-new commit that undoes the changes of the last commit; it does not change the commit message. 'git reset --soft HEAD~1' undoes the last commit but keeps the changes staged, so the developer would need to re-commit everything — it doesn't simply fix the message. 'git commit --fixup' creates an additional fixup commit intended for use with interactive rebase; it does not directly amend the message.

Test yourself across every GH-900 domain

The free GH-900 practice test mixes about 20 questions weighted like the exam. The full 150-question bank adds instant grading, flashcards and a timed mock exam.

Study this domain

Work with GitHub Repositories study guide (GH-900) →

Other GH-900 domains

← All GitHub Foundations study resources