Exercises
Sharpen your Git skills with this quiz on branching and merging. Test your understanding of default branch names, creating, switching, viewing, comparing, and deleting branches. Explore why teams use merges to combine work, learn the command for merging changes into an active branch, and check your knowledge of merge conflicts and fast-forward merges. Whether you are new to version control or reviewing core Git workflows, these questions cover essential commands and concepts for managing parallel development safely and effectively.
Answer the questions below and check the explanation for each answer.
0/10 answered
Auto audio on: the next questions will be read aloud when you click Continue.
In 2020, GitHub changed the default branch name from master to main to promote inclusive language. Consequently, main has become the default branch name in new repositories created on many Git platforms, including GitHub.
The git checkout -b command is used to create a new branch and switch to it immediately. It is a common way to create branches while working on new features or experiments in a separate part of the codebase without affecting the main project branch.
The command git checkout is used to switch branches in Git, so it is the correct option. The git swap command does not exist in Git, and git branch -m is used to rename a branch, not switch to it.
In Git, to delete a branch, you use the command git branch -d. This is the safe way to delete a branch that has been fully merged into your current working branch. If the branch hasn’t been merged yet, you may use git branch -D to forcefully delete it.
Merging in Git is the process of integrating changes from one branch into another. This allows different lines of development to be combined, preserving the history and merging the content from both branches into a unified whole. Unlike options that suggest creating or deleting branches, merging is specifically for combining changes.
The correct command to merge changes from one branch to your active branch is git merge. This command takes the changes from a specified branch and applies them to the branch you're currently working on.
A merge conflict in Git occurs when Git cannot automatically resolve differences in code between two commits. This happens when changes in different branches overlap or contradict each other, and Git is unable to determine which changes should be integrated. Developers must manually resolve these conflicts by editing the code and staging the resolved files before completing the merge process.
To view all branches in your Git repository, you use the git branch command. This command lists all the branches that exist locally in your repository, highlighting the current branch with an asterisk (*).
The git diff command is used to compare changes between branches in Git. It shows the differences in code between two commit points or between a commit and the current branch. git compare and git contrast are not valid Git commands.
A 'fast-forward' merge in Git occurs when the target branch has no new commits since the source branch diverged. The target branch pointer is simply moved to point at the same commit as the source branch. This is possible because there are no changes to reconcile, making it a straightforward operation without actual merging of code or creation of merge commits.

Free CourseGit and GitHub
4h02m
5 exercises

Free CourseDocker Containers and Kubernetes Fundamentals
5h56m
6 exercises

Free CourseJenkins
3h53m
20 exercises

Free CourseUse ChatGPT for DevOps tasks
1h07m
6 exercises

Free CourseKubernetes for Beginners
3h36m
6 exercises

Free CourseGit and Git Hub
2h00m
54 exercises

Free CourseGoogle Chrome dev tools
51m

Free CourseEthical hacking for beginners
21h06m
13 exercises
Thousands of online courses in video, ebooks and audiobooks.
To test your knowledge during online courses
Generated directly from your cell phone's photo gallery and sent to your email
Download our app via QR Code or the links below:.
+ 10 million
students
Free and Valid
Certificate
60 thousand free
exercises
4.8/5 rating in
app stores
Free courses in
video and ebooks