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?✗ Incorrect
git push origin --delete bugfix deletes the remote branch named bugfix. git branch -d deletes local branches only.
What does
git fetch --prune do in relation to remote branches?✗ Incorrect
git fetch --prune updates your local list of remote branches and removes references to remote branches that no longer exist.
If you want to delete a remote branch but keep your local copy, what should you do?
✗ Incorrect
Deleting the remote branch with git push origin --delete branch does not affect your local branch.
What will happen if you run
git push origin --delete nonexist when nonexist branch does not exist on remote?✗ Incorrect
Git will show an error because the branch does not exist on the remote.
Which command is an older syntax to delete a remote branch named
test?✗ Incorrect
git push origin :test deletes the remote branch test using older syntax by pushing an empty reference.
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.