Episode 14 of 14

Deleting Branches

Learn about Deleting Branches

Why delete branches: Once a feature branch has been successfully merged, it clutters your repository and should be removed. Delete a merged branch: Run the command git branch -d followed by the branch name to safely delete it. Safeguard mechanism: The lowercase -d flag will prevent you from deleting a branch that has unmerged changes. Force delete a branch: If you want to throw away an experimental branch that you never intend to merge, you must force the deletion. Execute force delete: Run git branch -D with an uppercase D followed by the branch name to permanently delete it regardless of its merged status. Impact on history: Deleting a branch pointer does not delete the commits; those remain part of the project history if they were merged.