0
0
Gitdevops~20 mins

Deleting branches in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Branch Deletion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of deleting a local branch
What is the output of the command git branch -d feature1 if the branch feature1 has been fully merged into main?
Git
git branch -d feature1
ADeleted branch feature1 (was abc1234).
Berror: The branch 'feature1' is not fully merged.
Cfatal: branch 'feature1' not found.
Dwarning: branch 'feature1' is currently checked out.
Attempts:
2 left
💡 Hint
Deleting a branch that is fully merged succeeds with a confirmation message.
💻 Command Output
intermediate
1:30remaining
Error when deleting unmerged local branch
What error message appears when running git branch -d feature2 if feature2 has unmerged changes?
Git
git branch -d feature2
ADeleted branch feature2 (was def5678).
Berror: The branch 'feature2' is not fully merged.
Cfatal: branch 'feature2' not found.
Dwarning: branch 'feature2' is currently checked out.
Attempts:
2 left
💡 Hint
The -d option refuses to delete branches with unmerged changes.
💻 Command Output
advanced
1:30remaining
Deleting a remote branch output
What is the output of the command git push origin --delete feature3 when the remote branch feature3 exists and is deleted successfully?
Git
git push origin --delete feature3
Afatal: unable to delete branch feature3
Berror: remote ref does not exist
C
To origin
 - [deleted]         feature3
Dwarning: branch 'feature3' is currently checked out.
Attempts:
2 left
💡 Hint
Successful remote deletion shows the branch name with [deleted].
Troubleshoot
advanced
2:00remaining
Troubleshooting remote branch deletion failure
You run git push origin --delete feature4 but get the error error: unable to delete 'feature4': remote ref does not exist. What is the most likely cause?
AThe branch 'feature4' does not exist on the remote repository.
BYou do not have permission to delete branches on the remote.
CThe local branch 'feature4' is currently checked out.
DThe remote repository is unreachable due to network issues.
Attempts:
2 left
💡 Hint
The error says the remote ref does not exist.
Best Practice
expert
2:30remaining
Best practice for safely deleting branches
Which option describes the safest practice to delete a local branch that might have unmerged work?
AUse <code>git branch -D branch_name</code> to force delete without checking merge status.
BDelete the branch directly on the remote without checking local branches.
CRename the branch instead of deleting to keep history.
DUse <code>git branch -d branch_name</code> and verify merge status before deleting.
Attempts:
2 left
💡 Hint
Safe deletion avoids losing unmerged work.