It's common to need to remove old git branches. It's almost a day to day task that the most of developers do.
To The Point
Before you start removing your branches you should checkout to master with :
git checkout origin/master
Removing a local branch
git branch -D name-of-branch
Removing a branch on remote
BEAWARE This will make a request to git server to remove branch on remote!
git push origin :name-of-branch-to-remove-on-git-server
Removing local branches stale on remote
With fetching
git fetch -p
Only removing
git remote origin prune
Snippets
git fetch -p
git remote origin prune
BONUS
After some digging I've found there is a better git-command that can be used to prune - and it's git-prune
- unfortunatelly it's available from 2.16.0
version, and as I've found out with :
git --version
I was using a 1.9.1
version :/
Let's change that:
Update git to latest version
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install -y git
Now for Ubuntu 14.04 I have a 2.16.2
version.
Acknowledgements
Auto-promotion
Related links
- Git Housekeeping Tutorial
- How can I update to a newer version of git using apt-get
- Git-Prune git-command reference
- Git stable releases on Ubuntu PPA
Thanks!
That's it :) Comment, share or don't :)
If you have any suggestions what I should blog about in the next articles - please give me a hint :)
See you in the next episode! Cheers!
Comments
comments powered by Disqus