readyforhires

Advanced Git test (Advanced)

40 questions · 40 minutes · Free

Git internals, large repos, hooks and recovery.

Take the Advanced Git test

What it covers

Interview format

Earn a certificate

The Advanced Git test is one of the 8 tests of the Software Engineer (Java): Advanced learning path. Pass it and the other 7 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for Software Engineer (Java): Advanced, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Advanced Git test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. What happens if a client-side Git hook (e.g., `pre-push`) fails during a push operation?

    1. The user is prompted to confirm the push despite the hook failure.
    2. The hook is automatically retried until it succeeds.
    3. The commit is pushed, and the hook is ignored.
    4. The commit is rejected, and the push is aborted.

    Answer: D. The commit is rejected, and the push is aborted.

    If a client-side Git hook (such as `pre-commit` or `pre-push`) fails (returns a non-zero exit code), Git aborts the operation that triggered the hook. For example, if `pre-push` fails, the push is aborted, and the user is notified of the failure. This ensures that invalid or incomplete changes are not pushed to the remote repository.

  2. In a Git repository, where will the object with the SHA-1 hash '4bf8c3b5d6e10a69d2f742a125e9678e1a3c9d0e' be stored based on the fanout calculation?

    1. The objects will be stored in the .git/objects/4c/ directory.
    2. The objects will be stored in the .git/objects/4b/ directory.
    3. The objects will be stored in the .git/objects/4a/ directory.
    4. The objects will be stored in the .git/objects/4e/ directory.

    Answer: B. The objects will be stored in the .git/objects/4b/ directory.

    Git uses the first two hexadecimal characters of an object's SHA-1 hash to determine the subdirectory in which the object is stored. For the hash '4bf8c3b5d6e10a69d2f742a125e9678e1a3c9d0e', the first two characters are '4b', so the object will be stored in the '.git/objects/4b/' directory.

  3. What is the correct method for recovering a deleted branch in Git?

    1. Run `git fsck --lost-found` and search for the branch in the output.
    2. Find the last commit SHA of the branch in the reflog, then run `git branch <branch-name> <sha>`.
    3. Use `git log --all` to find the branch and then recreate it.
    4. Run `git reflog` and manually copy the branch name from the output.

    Answer: B. Find the last commit SHA of the branch in the reflog, then run `git branch <branch-name> <sha>`.

    When a branch is deleted, its commits are not immediately removed from the repository. The reflog retains information about where the branch pointed before deletion. To recover it, you can find the last commit SHA of the branch in the reflog and recreate the branch with that commit. Other options are incorrect because they do not accurately describe the process of recovering a deleted branch.

  4. Which of the following statements about git fsck is true?

    1. git fsck can identify corrupted objects in the repository.
    2. git fsck is responsible for creating commit objects.
    3. git fsck manages the reflog retention period.
    4. git fsck is used for delta compression of packfiles.

    Answer: A. git fsck can identify corrupted objects in the repository.

    git fsck is a command used to verify the integrity of Git objects. It can detect missing or corrupted objects, making it a crucial tool for ensuring the health of a repository. The other options are incorrect because git fsck does not directly interact with packfiles for compression, does not manage reflog retention periods, and does not perform delta compression itself.

  5. Which of the following correctly describes how to recover a deleted branch in Git?

    1. Use `git fsck --lost-found` to directly recover a deleted branch.
    2. Recover a deleted branch: find its last SHA in the reflog, then `git branch name <sha>`.
    3. The reflog only stores information about commits, not branches.
    4. A deleted branch cannot be recovered once it is removed from the repository.

    Answer: B. Recover a deleted branch: find its last SHA in the reflog, then `git branch name <sha>`.

    The reflog records where `HEAD` and each branch pointed, allowing you to recover a deleted branch by finding its last SHA in the reflog and creating a new branch pointing to that commit. Other options are incorrect because they describe unrelated Git operations or misconceptions about the reflog.

Frequently asked questions

How many questions are in the Advanced Git test?
40 questions (24 multiple choice, 16 multi-answer), with 40 minutes to answer them.
What does the Advanced Git test cover?
Objects, refs and packfiles, Interactive rebase and bisect, Hooks and automation, Submodules and monorepos, Recovering lost work.
Is the Advanced Git test free?
Yes. It is free to take with a readyforhires account.
What level is the Advanced Git test?
Advanced, in DevOps & cloud.

More DevOps & cloud tests

Roles that test these skills

Companies that test these skills

All practice tests · All DevOps & cloud tests

Last updated