Essential Concepts of Git Branching, Merging, and Conflict Resolution Quiz

Explore key concepts of version control branching, merging, and resolving conflicts in Git and collaborative development workflows. Challenge your understanding of safe code integration, branch management, and conflict resolution best practices while learning practical application scenarios in modern tool ecosystems.

  1. Understanding Git Branch Creation

    Which command creates a new branch called 'feature1' based on your current branch in a repository?

    1. git checkout feature1
    2. git make branch feature1
    3. git branch feature1
    4. git create-branch feature1

    Explanation: The command 'git branch feature1' creates a new branch named 'feature1' from your current branch. 'git create-branch feature1' and 'git make branch feature1' are incorrect because those commands do not exist in Git. 'git checkout feature1' is used to switch to an existing branch or create and switch in newer versions with '-b', but on its own does not create the branch if it doesn't exist.

  2. Switching Between Branches

    If you want to work on a different branch named 'dev', which command should you use to switch to it?

    1. git checkout dev
    2. git branch dev
    3. git start dev
    4. git change dev

    Explanation: 'git checkout dev' allows you to switch to the branch named 'dev', making it your working branch. 'git branch dev' creates a new branch but does not switch to it. The commands 'git start dev' and 'git change dev' are not valid in Git, so they would result in errors.

  3. Merging Branches Correctly

    Suppose you have finished work on your 'featureX' branch and want to integrate its changes into 'main'. Which command should you use on 'main'?

    1. git combine featureX
    2. git join featureX
    3. git merge featureX
    4. git connect featureX

    Explanation: The correct way to combine the changes from 'featureX' into 'main' is using 'git merge featureX' while on 'main'. 'git combine', 'git connect', and 'git join' are not valid Git commands and would result in command errors if executed.

  4. Branch Deletion After Merge

    After successfully merging and finishing a feature, which command safely deletes the local branch named 'old-feature'?

    1. git branch --remove old-feature
    2. git branch -d old-feature
    3. git delete branch old-feature
    4. git remove-branch old-feature

    Explanation: You can remove a local branch using 'git branch -d old-feature', which deletes the branch if it has been merged. 'git delete branch old-feature', 'git remove-branch old-feature', and 'git branch --remove old-feature' are not valid commands in Git for branch deletion.

  5. Identifying a Merge Conflict

    When merging branches, what typically triggers a merge conflict in a version control system?

    1. Adding new, different files in each branch
    2. Deleting unrelated files in both branches
    3. Switching branches without commit
    4. Changing the same line in the same file on both branches

    Explanation: A merge conflict occurs when changes have been made to the same line in a file on both branches, and Git cannot automatically decide which version to keep. Deleting unrelated files or adding new files in each branch generally does not cause conflicts. Simply switching branches without a commit won’t cause a merge conflict.

  6. Conflict Markers in Files

    After a merge conflict, which markers are inserted in the affected file to indicate conflicting changes?

    1. u003Cu003C--, ==, --u003Eu003E
    2. u003Eu003Eu003Eu003E, ====, u003Cu003Cu003Cu003C
    3. u003Cu003Cu003Cu003Cu003Cu003Cu003C, =======, and u003Eu003Eu003Eu003Eu003Eu003Eu003E
    4. {conflict start}, {conflict split}, {conflict end}

    Explanation: The lines 'u003Cu003Cu003Cu003Cu003Cu003Cu003C', '=======', and 'u003Eu003Eu003Eu003Eu003Eu003Eu003E' are used as markers in files to highlight conflicting sections after a merge. The other options are not actual markers used by Git; they are incorrect or made-up formats that do not occur in conflict files.

  7. Resolving Merge Conflicts

    Once you have manually fixed a conflict in a file, which command should you run to mark the file as resolved?

    1. git add filename
    2. git accept filename
    3. git solved filename
    4. git resolve filename

    Explanation: You should use 'git add filename' to mark a conflicted file as resolved after editing it. 'git resolve', 'git solved', and 'git accept' are not valid Git commands for this purpose and will result in errors.

  8. Checking Current Branch

    Which command shows the branch you are currently working on in a Git repository?

    1. git history
    2. git log-branch
    3. git show-branch
    4. git branch

    Explanation: 'git branch' lists all branches and highlights the current branch with an asterisk. 'git history' and 'git log-branch' are not standard commands, while 'git show-branch' shows branch relationships but does not directly indicate the current branch.

  9. Undoing a Merge Before Committing

    If you start a merge and encounter problems before committing, which command can you use to abort and return to the pre-merge state?

    1. git merge --abort
    2. git abort-merge
    3. git cancel merge
    4. git undo-merge

    Explanation: 'git merge --abort' is used to stop the merge process and return the repository to the state before the merge, if conflicts or issues arise. The commands 'git undo-merge', 'git abort-merge', and 'git cancel merge' are not valid in Git and will not perform this operation.

  10. Purpose of Branching in Version Control

    Why is branching a useful feature in a collaborative version control system?

    1. It allows multiple users to work on different features or bug fixes independently.
    2. It permanently deletes files from the project.
    3. It slows down the workflow to increase accuracy.
    4. It automatically merges all changes from everyone without review.

    Explanation: Branching enables multiple users to work on separate changes without interfering with each other's progress, improving collaboration and workflow efficiency. Branching does not permanently delete files, slow down workflow, or automatically merge changes without review; these are misunderstandings or incorrect uses.