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.
Which command creates a new branch called 'feature1' based on your current branch in a repository?
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.
If you want to work on a different branch named 'dev', which command should you use to switch to it?
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.
Suppose you have finished work on your 'featureX' branch and want to integrate its changes into 'main'. Which command should you use on 'main'?
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.
After successfully merging and finishing a feature, which command safely deletes the local branch named '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.
When merging branches, what typically triggers a merge conflict in a version control system?
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.
After a merge conflict, which markers are inserted in the affected file to indicate conflicting changes?
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.
Once you have manually fixed a conflict in a file, which command should you run to mark the file as resolved?
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.
Which command shows the branch you are currently working on in a Git repository?
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.
If you start a merge and encounter problems before committing, which command can you use to abort and return to the pre-merge state?
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.
Why is branching a useful feature in a collaborative version control system?
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.