Git & Version Control test (Beginner)
25 questions · 30 minutes · Free
Branching, merging, rebasing and recovering from mistakes.
Take the Git & Version Control test
What it covers
- Commits and the index
- Merge vs rebase
- Resolving conflicts
- reflog and reset
- Branching strategies
Interview format
- Questions: 25 questions — 15 multiple choice, 10 multi-answer
- Time: 30 minutes, timed from the first question
- Difficulty: Beginner
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Git & Version Control test is one of the 8 tests of the Software Engineer (Java) 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 questions
5 sample questions from the Git & Version Control test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
What is the correct process to resolve a merge or rebase conflict in Git?
- Run 'git merge --abort' and then 'git rebase --continue'.
- Edit the file, remove the conflict markers, run 'git add file', and then 'git commit' or 'git rebase --continue'.
- Ignore the conflict markers and run 'git commit --amend'.
- Run 'git checkout --ours file' and then 'git commit'.
Answer: B. Edit the file, remove the conflict markers, run 'git add file', and then 'git commit' or 'git rebase --continue'.
When resolving a merge or rebase conflict, the correct process involves editing the file to resolve the conflict, removing the conflict markers, staging the resolved file with 'git add', and then committing or continuing the rebase. Other options may be incorrect because they may not fully address the resolution process or may involve incorrect commands.
Which statement correctly describes the relationship between the Git reflog and the standard `git log`?
- The Git reflog only tracks changes to the working directory, not the index or HEAD.
- The Git reflog retains information about changes to the HEAD and staging area for a longer period than the standard log.
- The Git reflog is automatically cleared after a certain period, unlike the standard log.
- The Git reflog and standard log have identical retention policies and data storage.
Answer: B. The Git reflog retains information about changes to the HEAD and staging area for a longer period than the standard log.
The Git reflog is a log of all changes to the HEAD and staging area, making it useful for recovery after operations like resets or reverts. In contrast, the standard `git log` only shows the history of commits and does not track changes to the HEAD or index. Therefore, the reflog retains more information for a longer period, which is critical for recovery purposes.
Which Git command is used to create a new branch that tracks a remote branch, ensuring proper upstream configuration?
- git checkout -b
- git branch --track
- git remote add
- git pull --rebase
Answer: B. git branch --track
The `git branch --track` command is used to create a new branch that tracks a remote branch. This setup ensures that Git knows which remote branch to push to and pull from, improving performance and reducing ambiguity in branch management.
What is the purpose of the staging area (or index) in Git?
- The staging area is used to store committed history and is accessed through the repository.
- The staging area is the same as the working directory and contains the actual files on the disk.
- The staging area is a read-only area that cannot be modified by developers.
- The staging area (or index) is a temporary holding area for changes before they are committed.
Answer: D. The staging area (or index) is a temporary holding area for changes before they are committed.
The staging area (or index) is a temporary holding area for changes before they are committed. It allows developers to selectively choose which changes to include in the next commit. This is different from the working directory, which contains the actual files on the disk, and the repository, which contains the committed history.
What is the correct description of the rebase workflow in Git?
- Rebase is a fast-forward merge that moves the branch pointer without creating a new commit.
- Rebase creates a merge commit with two parents, combining the histories of two branches.
- Rebase is a command that automatically resolves conflicts and creates a new branch with merged changes.
- Rebase replays your commits on top of another base, creating new commits with new hashes and a linear history.
Answer: D. Rebase replays your commits on top of another base, creating new commits with new hashes and a linear history.
Rebase is a process where your commits are replayed on top of another base, resulting in new commits with new hashes and a linear history. This is different from merge, which combines branches and creates a merge commit. Rebase is useful for maintaining a clean, linear history, but it should not be used on shared branches because it rewrites commit history.
Frequently asked questions
- How many questions are in the Git & Version Control test?
- 25 questions (15 multiple choice, 10 multi-answer), with 30 minutes to answer them.
- What does the Git & Version Control test cover?
- Commits and the index, Merge vs rebase, Resolving conflicts, reflog and reset, Branching strategies.
- Is the Git & Version Control test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Git & Version Control test?
- Beginner, in DevOps & cloud.