0
0
Gitdevops~5 mins

Deleting branches in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
How do you delete a local Git branch named feature1?
Use the command git branch -d feature1 to delete the local branch feature1. This only works if the branch is fully merged.
Click to reveal answer
intermediate
What command force deletes a local Git branch even if it is not merged?
Use git branch -D branch_name to force delete a local branch regardless of merge status.
Click to reveal answer
beginner
How do you delete a remote Git branch named feature1?
Use git push origin --delete feature1 to delete the remote branch feature1 from the remote repository.
Click to reveal answer
beginner
What happens if you try to delete the branch you are currently on?
Git will not allow deleting the branch you are currently on. You must switch to a different branch first.
Click to reveal answer
intermediate
Why should you be careful when force deleting branches?
Force deleting branches can cause loss of unmerged work. Always double-check before using -D to avoid losing important changes.
Click to reveal answer
Which command deletes a local Git branch only if it is fully merged?
Agit branch -D branch_name
Bgit delete branch_name
Cgit push origin --delete branch_name
Dgit branch -d branch_name
How do you delete a remote branch named feature1?
Agit branch -d feature1
Bgit remote delete feature1
Cgit push origin --delete feature1
Dgit branch -D feature1
What does the -D option do when deleting a branch?
AForce deletes a local branch even if unmerged
BDeletes remote branches
CDeletes only merged branches
DDeletes the current branch
What must you do before deleting the branch you are currently on?
ANothing, you can delete it directly
BSwitch to a different branch
CPush the branch to remote
DMerge it with master
Why is it risky to force delete a branch?
AIt can cause loss of unmerged work
BIt deletes the remote branch too
CIt slows down Git performance
DIt creates a new branch automatically
Explain how to safely delete a local Git branch and what precautions to take.
Think about merge status and current branch.
You got /4 concepts.
    Describe the steps to delete a remote Git branch and why it might be necessary.
    Consider remote repository management.
    You got /3 concepts.