Creating a Feature Branch
What is the correct Git command to create a new branch called 'feature/add-login' and switch to it immediately?
- git checkout -b feature/add-login
- git create branch feature/add-login
- git switchto feature/add-login
- git new branch feature/add-login
- git branch -c feature/add-login
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?
- To isolate your changes and prevent interfering with stable code
- Because main branch is slower to work on by default
- To save disk space on your computer
- Branches automatically deploy to production
- Because 'main' does not track new commits
Merging Branches
If you want to integrate changes from the 'feature/cart' branch into your current branch, which command should you use?
- git merge feature/cart
- git push feature/cart
- git rebase feature/cart
- git pull feature/cart
- git add feature/cart
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?
- Manually edit the conflicting files to resolve issues, then commit the changes
- Delete both branches and start over
- Ignore the conflict and continue working
- Push your code without resolving to remote
- Run 'git fix-conflicts' to automatically resolve
Keeping Branches Updated
How do you regularly update your feature branch with the latest changes from the 'main' branch?
- git pull origin main into your feature branch
- git copy main feature
- git download main
- git move main feature
- git push main
Branch Naming Best Practices
Why is it recommended to use descriptive branch names such as 'bugfix/user-login-error'?
- To clarify the purpose of the branch for your team
- Because short names are not supported
- Descriptive names are required by Git syntax
- To reduce the branch size
- Only descriptive names allow merging
Pushing a New Branch
After creating a local branch called 'feature/search', which command will upload it to the remote repository?
- git push -u origin feature/search
- git upload branch feature/search
- git add feature/search
- git origin feature/search
- git commit -r feature/search
Pull Requests and Collaboration
What is the primary purpose of opening a pull request in platforms like GitHub or GitLab?
- To propose merging your branch into another and request code review
- To force deploy code changes
- To delete old branches automatically
- To squash commits in a branch
- To back up the repository
Branch Deletion
Once a feature branch has been merged and is no longer needed, how can you remove it locally?
- git branch -d feature/login-form
- git branch remove feature/login-form
- git delete feature/login-form
- git remove-branch feature/login-form
- git erase branch feature/login-form
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?
- Add upstream remote, fetch, then merge or rebase upstream/main into main
- Create a new branch and delete the old one
- Push changes from your local to upstream directly
- Edit remote URLs in .git/config and then push
- Only clone the repository again