Intermediate Git test (Intermediate)
30 questions · 35 minutes · Free
Rebasing, conflicts, branching strategies and history cleanup.
Take the Intermediate Git test
What it covers
- Rebase vs merge
- Resolving conflicts
- Branching strategies
- Cherry-pick and revert
- Stash and reflog
Interview format
- Questions: 30 questions — 18 multiple choice, 12 multi-answer
- Time: 35 minutes, timed from the first question
- Difficulty: Intermediate
- Skill area: DevOps & cloud
- Price: Free
Earn a certificate
The Intermediate Git test is one of the 8 tests of the Software Engineer (Java): Intermediate 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 Intermediate Git test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.
In a trunk-based development workflow, what is a common mistake that teams should avoid?
- The team should use a Git flow branching model with separate development and release branches.
- The team should avoid long-lived feature branches and integrate changes frequently into the trunk.
- The team should use long-lived feature branches and merge changes into the trunk once per sprint.
- The team should use feature branches that are merged into the trunk only after code review and testing.
Answer: B. The team should avoid long-lived feature branches and integrate changes frequently into the trunk.
Trunk-based development emphasizes short-lived feature branches and frequent integration into the main trunk. Long-lived branches can lead to integration challenges and outdated code, which goes against the principles of trunk-based development.
Which Git operation is typically used to combine changes from two branches while preserving their individual commit histories?
- Rebase
- Stash
- Merge
- Cherry-pick
Answer: C. Merge
When you perform a merge, Git creates a new commit that combines the changes from two branches. This is useful for preserving the history of both branches and is often preferred when working with public branches. Rebase, on the other hand, rewrites the commit history by applying changes from one branch onto another, which is more suitable for local branches and cleaning up history.
Which Git command is used to apply changes from one branch onto another while maintaining a linear history?
- git rebase
- git reset
- git push
- git merge
Answer: A. git rebase
When you want to integrate changes from one branch into another while maintaining a linear project history, 'git rebase' is the appropriate command. It rewrites the commit history by applying commits from one branch onto another. In contrast, 'git merge' creates a new merge commit, which is useful for preserving the history of both branches. 'git push' is for uploading local commits to a remote repository, and 'git reset' is for undoing changes in the working directory and staging area.
What is the primary difference between using Git rebase and Git merge?
- Rebase is used to create merge commits, while merge is used to apply changes from one branch to another.
- Rebase and merge both create merge commits and preserve the original branch history.
- Rebase is used for resolving conflicts, while merge is used to apply changes from one branch to another.
- Rebase creates a linear history, while merge preserves the original branch history.
Answer: D. Rebase creates a linear history, while merge preserves the original branch history.
Rebase is used to integrate changes from one branch into another by applying commits from one branch onto another, resulting in a linear history. Merge, on the other hand, combines the histories of two branches, preserving the original branch history and creating a merge commit. This distinction is key in understanding how to maintain clean and readable Git histories.
In a realistic project scenario, what is the difference between 'git stash drop' and 'git stash clear'?
- Stash drop and stash clear both remove all stashed changes.
- Stash drop and stash clear both remove specific stashed changes.
- Stash drop removes specific stashed changes, while stash clear removes all stashed changes.
- Stash drop removes all stashed changes, while stash clear removes specific stashed changes.
Answer: C. Stash drop removes specific stashed changes, while stash clear removes all stashed changes.
In a realistic project scenario, if a developer has multiple stashed changes and only wants to remove one, they would use 'git stash drop' with the reference to the specific stash. However, if they want to remove all stashed changes, they would use 'git stash clear'. This distinction is crucial for managing stashed changes effectively without unintended data loss.
Frequently asked questions
- How many questions are in the Intermediate Git test?
- 30 questions (18 multiple choice, 12 multi-answer), with 35 minutes to answer them.
- What does the Intermediate Git test cover?
- Rebase vs merge, Resolving conflicts, Branching strategies, Cherry-pick and revert, Stash and reflog.
- Is the Intermediate Git test free?
- Yes. It is free to take with a readyforhires account.
- What level is the Intermediate Git test?
- Intermediate, in DevOps & cloud.