Delete a Git branch both locally and remotely [Shell aliases + functions] #OneDevMinute

Ahmad Awais ⚡️ on September 24, 2018

Deleting a git branch locally is pretty easy, just do a git branch -D branch_name and you're done. But when you have already pushed that branch to ... [Read Full]
markdown guide

This is very helpful rather than Googling every time on how to delete a local and remote branch. Have you considered making a project with all your shell scripts? Something we can download use and contribute?


Super glad you liked it. I have started this #OneDevMinute series for this exact reason — share all of my workflows in mini chunks.

As I mentioned the 📨 Newsletter + site coming soon part where you'll be able to sign up.

For now, you can sub to my Twitter or YouTube — I actually made a funny gif for that, let me find that one.

Here it goes 🤣

Can't share it all, since it's not organized and has lots of moving parts + personal data in it.
I'm doing that with this series.

Peace! ✌️


Nice tip!

Any reason for using force to delete local branch though (git branch -D "$1", the d is majuscule)?

I think it'd be safer to use git branch -d "$1"



I think that's because it avoids the message of the branch not being merged?


Yes, so that means you lose your code (hence the force).

code of conduct - report abuse