github-developer-training-school / sonepar-training

Let's learn about Git and GitHub
https://github-developer-training-school.github.io/sonepar-training/
MIT License
0 stars 0 forks source link

Parking Lot #7

Open ncsokas opened 3 days ago

ncsokas commented 3 days ago

Post any questions you may have here during the training.

cristinelpirvulescu commented 3 days ago

Is there any difference between -d and -D on a branch delete command?

git branch -d <branch_name vs git branch -D <branch_name> - I've always used the latter, and I'm curious if there's any difference between the 2 flags.

Thank you!

ncsokas commented 2 days ago

Hi @cristinelpirvulescu ! Thank you for the question.

In short, -d (default) deletes a branch only if it’s fully merged into its upstream branch. -D deletes a branch regardless of its merge status.

So in terms of use cases: Use -d for safe, merge-aware branch deletion. Use -D with caution for forceful branch deletion (potential loss of data risk).