0
0
Gitdevops~5 mins

Deleting remote branches in Git - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the git command to delete a remote branch named feature1?
Use git push origin --delete feature1 to delete the remote branch named feature1.
Click to reveal answer
beginner
Why can't you delete a remote branch using git branch -d?
git branch -d deletes only local branches. To delete remote branches, you must use git push origin --delete <branch-name>.
Click to reveal answer
intermediate
What happens if you try to delete a remote branch that does not exist?
Git will show an error message saying the branch was not found on the remote. No changes happen on the remote repository.
Click to reveal answer
intermediate
How can you verify that a remote branch was deleted successfully?
Run git fetch --prune to update your local list of remote branches, then use git branch -r to see remote branches. The deleted branch should no longer appear.
Click to reveal answer
advanced
What is the difference between git push origin --delete branch and git push origin :branch?
Both commands delete the remote branch named branch. The first is more explicit and easier to understand, while the second uses an older syntax by pushing an empty reference.
Click to reveal answer
Which command deletes a remote branch named bugfix?
Agit branch -d bugfix
Bgit delete branch bugfix
Cgit remote remove bugfix
Dgit push origin --delete bugfix
What does git fetch --prune do in relation to remote branches?
ADeletes local branches
BUpdates local remote branch list and removes deleted remote branches
CCreates new remote branches
DPushes local branches to remote
If you want to delete a remote branch but keep your local copy, what should you do?
AUse <code>git push origin --delete branch</code> only
BUse <code>git branch -d branch</code>
CDelete local branch first
DUse <code>git remote prune origin</code>
What will happen if you run git push origin --delete nonexist when nonexist branch does not exist on remote?
AGit will show an error message
BNothing happens silently
CLocal branch will be deleted
DRemote branch will be created
Which command is an older syntax to delete a remote branch named test?
Agit push origin --delete test
Bgit branch -d test
Cgit push origin :test
Dgit remote delete test
Explain how to delete a remote branch in git and verify it was deleted.
Think about the push command and how to update your local view of remote branches.
You got /3 concepts.
    Describe the difference between deleting a local branch and a remote branch in git.
    Consider where the branch lives and which commands affect which.
    You got /3 concepts.