GitHub Foundations Free Sample Questions

Create a free account to browse all 17 sample questions. The full practice test includes 250 questions. Use the simulator for timed and flashcard mode.

Try Simulator

GH-900 Sample Questions

  1. Question 1

    Q1

    A development team is transitioning from a centralized version control system to Git and GitHub. They are confused about the distributed nature of Git compared to their previous system.

    Which statement accurately describes the fundamental architectural difference regarding repository history in this transition?

    Show answer & explanation

    Correct answer: B

    Git is a distributed version control system (DVCS). When a developer clones a repository, they receive a full backup of all data, including the entire commit history, branches, and tags. This allows operations like log viewing and diffing to happen locally without a network connection, unlike centralized systems where history resides primarily on the server.

  2. Question 2

    Q2

    You have initialized a new local project and created several files. You want to save the current state of your project to your local Git history.

    Which sequence of commands represents the correct workflow to permanently record these changes in the local repository?

    Show answer & explanation

    Correct answer: B

    The standard Git workflow involves two steps: first, staging the changes using git add (which moves files from the working directory to the staging area), and second, committing those staged changes to the local repository history using git commit. Pushing is a separate step to sync with a remote.

  3. Question 3

    Q3

    A developer attempts to push local commits to a remote repository but receives a 'non-fast-forward' error. This indicates that the remote branch contains commits that are not present locally.

    What is the safest command to resolve this situation without losing history, assuming the developer wants to incorporate the remote changes before pushing?

    Show answer & explanation

    Correct answer: B

    A git pull performs a git fetch followed by a git merge. This downloads the new commits from the remote and merges them into the local branch. Once the merge is resolved (and any conflicts fixed), the local history includes the remote work, allowing a standard git push to succeed. git push --force would overwrite remote history, potentially causing data loss for others.

  4. Question 4

    Q4

    You are investigating a bug in a specific file and need to identify exactly which commit introduced a specific line of code and who the author was.

    Which GitHub interface feature provides this line-by-line revision history?

    Show answer & explanation

    Correct answer: B

    The 'Blame' view (often called 'Annotate' in other tools) in GitHub displays the file content alongside the commit hash, author, and date for the last modification of every single line. This is the primary tool for tracing the origin of specific code changes.

  5. Question 5

    Q5

    A user needs to authenticate Git operations with GitHub using HTTPS but has Two-Factor Authentication (2FA) enabled on their account.

    What credential must they use in place of their account password when prompted by the command line?

    Show answer & explanation

    Correct answer: B

    When 2FA is enabled, basic password authentication is disabled for Git over HTTPS. Users must generate and use a Personal Access Token (PAT) with the appropriate scopes (like repo) as their password. Alternatively, they could use SSH keys or the Git Credential Manager.

  6. Question 6

    Q6

    You are working on a feature branch and want to incorporate the latest changes from the main branch into your work to ensure compatibility. You want to maintain a linear history without creating an extra merge commit.

    Which command should you use?

    Show answer & explanation

    Correct answer: B

    git rebase main rewrites the project history by creating new commits for each commit in the original branch, placing them after the last commit of the main branch. This creates a linear history, unlike git merge, which creates a special merge commit that ties the two histories together.

  7. Question 7

    Q7

    Which of the following files is ESSENTIAL for excluding specific local files, such as build artifacts or environment secrets, from being tracked by Git?

    Show answer & explanation

    Correct answer: B

    The .gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; it prevents new files (like log files, binaries, or .env files) from being accidentally staged and committed.

  8. Question 8

    Q8Multiple answers

    Select TWO valid reasons for 'forking' a repository instead of 'cloning' it in the GitHub ecosystem. (Select TWO)

    Show answer & explanation

    Correct answers: A, C

    Forking creates a personal copy of the repository on your GitHub account. This is essential for contributing to open-source projects where you lack permission to push directly to the original (upstream) repository.

    Forking is also used to take an existing project and diverge it into a new, separate project (often called a 'hard fork') that you manage independently.

Register free to unlock 9 more sample questions

Create a free account to continue with the rest of the GH-900 sample set.

Lifetime One

Own this practice test forever.

$79.99
$75.99
one-time
  • Full access to 250 questions
  • Study, Timed & Flashcard Modes
  • All past and future versions i
  • Detailed Explanations
  • Study Tracking & Past Attempts
  • Brainy AI Assistant
  • Lifetime updates

Two

Any 2 exams per month.

$20.00/exam
$39.99
/month
  • 2 active exam slots
  • Study, Timed & Flashcard Modes
  • All past and future versions i
  • Detailed Explanations
  • Study Tracking & Past Attempts
  • 1,000 Brainy AI Credits
  • Cancel anytime

Premium Twelve

Any 12 exams over 3 months.

$15.00/exam
$179.99
/3 months
  • 4 active exam slots
  • Study, Timed & Flashcard Modes
  • All past and future versions i
  • Detailed Explanations
  • Study Tracking & Past Attempts
  • 15,000 Brainy AI Credits
  • Dedicated support
  • Friend seat included — full access

Trusted by professionals at

NvidiaSupabaseGitHubOpenAITursoClerkClaude AIAmazon