Why are branches important when working with Git?
Think about how teams work on different tasks at the same time.
Branches let developers work on separate features or fixes independently. This keeps the main code stable and avoids conflicts until changes are ready to merge.
What is the output of running these commands in order?
git branch feature1 git checkout feature1 git branch
The asterisk (*) shows the current branch.
After creating and switching to 'feature1', the current branch is 'feature1'. The 'git branch' command lists branches with '*' marking the active one.
What is the correct order of commands to create a feature branch, work on it, and merge it back to main?
Create branch first, then add and commit changes, switch back to main, then merge.
You first create and switch to the feature branch, add and commit your changes there, then switch back to main and merge the feature branch.
You try to merge a feature branch into main but get a conflict. What should you do next?
Conflicts need manual fixing before completing the merge.
When a merge conflict happens, you must open the files, fix the conflicting parts, then stage and commit the resolved files to complete the merge.
Why is it best practice to keep feature branches short-lived in Git?
Think about how long branches stay separate and how that affects merging.
Keeping branches short-lived means changes are merged back quickly, reducing the chance of conflicts and keeping the project clean and easier to manage.