GitHub Foundations Free Sample Questions

Description

Covers Git basics and navigating GitHub, managing repository settings and files, collaboration and project management features, DevOps practices and code review, and the community.

17 free sample questions250 in the full practice test

Try simulator

GH-900 Sample Questions

  1. Question 1

    Intermediate

    Introduction to Git and GitHub · Understand the basics of Git

    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?

    Answer and explanation

    Correct answer: D

    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

    Beginner

    Introduction to Git and GitHub · Work with Git commands

    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?

    Answer and explanation

    Correct answer: D

    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

    Intermediate

    Introduction to Git and GitHub · Work with Git commands

    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?

    Answer and explanation

    Correct answer: A

    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

    Beginner

    Introduction to Git and GitHub · Navigate GitHub

    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?

    Answer and explanation

    Correct answer: A

    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

    Intermediate

    Introduction to Git and GitHub · Navigate GitHub

    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?

    Answer and explanation

    Correct answer: C

    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

    Advanced

    Introduction to Git and GitHub · Work with Git commands

    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?

    Answer and explanation

    Correct answer: C

    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

    Beginner

    Introduction to Git and GitHub · Navigate GitHub

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

    Answer and explanation

    Correct answer: A

    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

    IntermediateMultiple answers

    Introduction to Git and GitHub · Navigate GitHub

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

    Answer and explanation

    Correct answers: C, D

    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.

    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.

Register free for 9 more questions

Or unlock all 250 GH-900 questions with explanations, timed mode and flashcards.