How do you delete a remote branch in Git?

How do you delete a remote branch in Git?

a) git push origin --delete branch-name
b) git remove branch-name
c) git branch -d branch-name
d) git reset origin branch-name

Answer:

a) git push origin --delete branch-name

Explanation:

To delete a remote branch in Git, you use the git push origin --delete branch-name command. This removes the specified branch from the remote repository (e.g., GitHub).

For example, running git push origin --delete feature-branch will delete the feature-branch from the remote repository.

Deleting remote branches is useful for cleaning up after merging a feature branch or when a branch is no longer needed.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top