0
0
Gitdevops~20 mins

Deleting remote branches in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Remote Branch Deletion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of deleting a remote branch?
You run the command git push origin --delete feature-xyz. What will be the output if the branch feature-xyz exists on the remote?
Git
git push origin --delete feature-xyz
Afatal: 'feature-xyz' is not a valid branch
Berror: unable to delete 'feature-xyz': remote ref does not exist
C
To github.com:user/repo.git
 - [deleted]         feature-xyz
DBranch 'feature-xyz' deleted locally
Attempts:
2 left
💡 Hint
Deleting a remote branch shows a message with [deleted] if successful.
Troubleshoot
intermediate
2:00remaining
Why does deleting a remote branch fail?
You run git push origin --delete hotfix but get the error: error: unable to delete 'hotfix': remote ref does not exist. What is the most likely cause?
Git
git push origin --delete hotfix
AThe branch 'hotfix' does not exist on the remote repository.
BYou do not have permission to delete branches on the remote.
CThe local branch 'hotfix' is not checked out.
DThe remote repository URL is incorrect.
Attempts:
2 left
💡 Hint
The error says 'remote ref does not exist'.
🔀 Workflow
advanced
3:00remaining
Correct sequence to delete a remote branch safely
Arrange the steps in the correct order to safely delete a remote branch named feature-abc:
A2,1,3,4
B1,2,3,4
C1,3,2,4
D2,3,1,4
Attempts:
2 left
💡 Hint
You must confirm the branch exists before deleting and avoid deleting the branch you are currently on.
Best Practice
advanced
2:00remaining
Best practice for deleting remote branches in a team
Which practice is best when deleting remote branches in a shared repository?
AOnly delete remote branches if you are the repository owner.
BDelete remote branches immediately after pushing changes without communication.
CDelete remote branches by directly removing them from the remote server filesystem.
DAlways inform your team before deleting a remote branch to avoid disrupting others.
Attempts:
2 left
💡 Hint
Think about teamwork and communication.
🧠 Conceptual
expert
2:00remaining
What happens to local branches after deleting the remote branch?
You delete a remote branch release using git push origin --delete release. What is the state of your local branch named release after this command?
AThe local branch is automatically deleted.
BThe local branch remains unchanged and still exists.
CThe local branch is renamed to 'release-deleted'.
DThe local branch is reset to match the remote's default branch.
Attempts:
2 left
💡 Hint
Deleting a remote branch does not affect local branches automatically.