Quiz: Mastering Branches for Feature Development and Collaboration Quiz

  1. Creating a Feature Branch

    What is the correct Git command to create a new branch called 'feature/add-login' and switch to it immediately?

    1. git checkout -b feature/add-login
    2. git create branch feature/add-login
    3. git switchto feature/add-login
    4. git new branch feature/add-login
    5. git branch -c feature/add-login
  2. Understanding Branch Isolation

    When working on a new feature, why is it recommended to create a dedicated branch instead of working directly on the 'main' branch?

    1. To isolate your changes and prevent interfering with stable code
    2. Because main branch is slower to work on by default
    3. To save disk space on your computer
    4. Branches automatically deploy to production
    5. Because 'main' does not track new commits
  3. Merging Branches

    If you want to integrate changes from the 'feature/cart' branch into your current branch, which command should you use?

    1. git merge feature/cart
    2. git push feature/cart
    3. git rebase feature/cart
    4. git pull feature/cart
    5. git add feature/cart
  4. Collaboration and Dealing with Conflicting Changes

    What should you do if you encounter a merge conflict after merging your branch with another developer's branch?

    1. Manually edit the conflicting files to resolve issues, then commit the changes
    2. Delete both branches and start over
    3. Ignore the conflict and continue working
    4. Push your code without resolving to remote
    5. Run 'git fix-conflicts' to automatically resolve
  5. Keeping Branches Updated

    How do you regularly update your feature branch with the latest changes from the 'main' branch?

    1. git pull origin main into your feature branch
    2. git copy main feature
    3. git download main
    4. git move main feature
    5. git push main
  6. Branch Naming Best Practices

    Why is it recommended to use descriptive branch names such as 'bugfix/user-login-error'?

    1. To clarify the purpose of the branch for your team
    2. Because short names are not supported
    3. Descriptive names are required by Git syntax
    4. To reduce the branch size
    5. Only descriptive names allow merging
  7. Pushing a New Branch

    After creating a local branch called 'feature/search', which command will upload it to the remote repository?

    1. git push -u origin feature/search
    2. git upload branch feature/search
    3. git add feature/search
    4. git origin feature/search
    5. git commit -r feature/search
  8. Pull Requests and Collaboration

    What is the primary purpose of opening a pull request in platforms like GitHub or GitLab?

    1. To propose merging your branch into another and request code review
    2. To force deploy code changes
    3. To delete old branches automatically
    4. To squash commits in a branch
    5. To back up the repository
  9. Branch Deletion

    Once a feature branch has been merged and is no longer needed, how can you remove it locally?

    1. git branch -d feature/login-form
    2. git branch remove feature/login-form
    3. git delete feature/login-form
    4. git remove-branch feature/login-form
    5. git erase branch feature/login-form
  10. Synchronizing with Upstream Changes

    If your team maintains a main upstream repository and you want to bring its recent changes into your fork’s main branch locally, which sequence of actions is correct?

    1. Add upstream remote, fetch, then merge or rebase upstream/main into main
    2. Create a new branch and delete the old one
    3. Push changes from your local to upstream directly
    4. Edit remote URLs in .git/config and then push
    5. Only clone the repository again