Explore fundamental concepts of git branch management, including branching strategies, merging, conflict resolution, and best practices. This quiz helps reinforce key skills for effective version control in collaborative development workflows.
Which command should you use to create a new branch called 'featureX' from your current branch in git?
Explanation: The 'git branch featureX' command creates a new branch named 'featureX' without switching to it. 'git checkout featureX' tries to switch to an existing branch, not create one. 'git clone featureX' is used for cloning repositories, not branches. 'git start featureX' is not a valid git command. Only the correct answer successfully adds a new branch to the repository.
You are currently working on 'main' with uncommitted changes and want to switch to 'bugfix'. What is the safest way to do this in git?
Explanation: Committing or stashing your changes ensures you don't lose work or cause conflicts when switching branches. Git fetch updates remote tracking branches but does not switch your current branch. Deleting 'main' risks losing important data and isn’t necessary for branch switches. Running 'git merge bugfix' attempts a merge, not a branch switch.
What is the most likely reason for encountering a merge conflict when merging one branch into another in git?
Explanation: A merge conflict typically happens when the same lines in a file are changed differently on both branches. No common history may prevent merging entirely rather than causing a conflict. Using 'git commit' alone cannot cause a conflict, and branch naming does not cause conflicts—content changes do.
After finishing work, which command properly deletes a local branch named 'old-feature' in git?
Explanation: The correct command to delete a local branch is 'git branch -d old-feature'. 'git remove branch old-feature', 'git discard old-feature', and 'git delete-branch old-feature' are not valid git commands and will result in errors. Always use the documented branch deletion option.
What is the main purpose of merging a feature branch into the main branch in git?
Explanation: Merging a feature branch into the main branch incorporates completed work into the primary development stream. Cloning a repository is unrelated to merging. Deleting a branch is a separate action performed after merging if desired. Resetting the repository is used for rewinding history and not related to merging feature branches.