Bird
0
0

You want to delete multiple remote branches named feature1, feature2, and feature3 in one command using the --delete flag. Which of the following is the correct way to do this?

hard📝 Best Practice Q15 of 15
Git - Remote Repositories
You want to delete multiple remote branches named feature1, feature2, and feature3 in one command using the --delete flag. Which of the following is the correct way to do this?
Agit push origin :feature1 :feature2 :feature3
Bgit push origin --delete feature1 && git push origin --delete feature2 && git push origin --delete feature3
Cgit push origin --delete feature1 feature2 feature3
Dgit branch -r -d feature1 feature2 feature3
Step-by-Step Solution
Solution:
  1. Step 1: Understand multi-branch deletion syntax

    Git does not support deleting multiple remote branches in one command by listing them after --delete. You must run separate commands or use multiple --delete flags.
  2. Step 2: Evaluate options

    git push origin --delete feature1 feature2 feature3 is invalid syntax and will cause an error. git push origin --delete feature1 && git push origin --delete feature2 && git push origin --delete feature3 runs multiple commands separately, which works correctly. git push origin :feature1 :feature2 :feature3 uses old syntax without the --delete flag and may not be recommended. git branch -r -d feature1 feature2 feature3 deletes local remote-tracking branches, not remote branches.
  3. Final Answer:

    git push origin --delete feature1 && git push origin --delete feature2 && git push origin --delete feature3 -> Option B
  4. Quick Check:

    Multiple remote branches deleted by running separate commands with --delete [OK]
Quick Trick: Run separate 'git push origin --delete branch' commands to remove multiple remotes [OK]
Common Mistakes:
  • Trying to delete multiple branches with old syntax
  • Using invalid multi-branch --delete syntax
  • Confusing local remote-tracking branch deletion with remote
  • Not listing all branches after --delete

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes