In the last month I read "Pro Git" book [1]. Sometimes I stumble upon something really interesting or useful I didn't know before. I decided to share some tips with you from time to time, since it can help all of us in our day-to-day work. If you have some further tips, don't be afraid to share.
Today's menu of git tips says "pruning stale remote-tracking branches":
You probably know "git remote" command. It shows information about your remote repositories. Try this one out:
$ git remote show origin
What you might not know is that this command allows you to prune all your local branches that track an already-deleted remote branch.
I often remove remote feature branches after the changes have been merged into master and the branch is not needed anymore, in order to "tidy up". But if you checked out that branch into your local one and set it as tracking, "git pull" won't delete such local branches for you. So how do you know which local branches doesn't exist on the server anymore? Easily, just run:
$ git remote prune origin --dry-run
and you'll receive a list of your stale remote-tracking branches. If you run it without --dry-run option, it will remove them for you.
Happy gitting!
The series continues! :-)
You've surely seen this scenario:
You have just prepared the patch and you want to commit it. But when you run: $ git commit and you want to describe the changes, you are not sure whether you remember all of them. So you must fire up another terminal, display the diff and ensure the commit message covers all the major points.
But there's a nice solution:
$ git commit -v
This will display the diff *inside* the commit message editor, so you can go through all the changes in the same window in which you're describing them. I find it very convenient.
Some of you may probably even want to create an alias for it:
$ git config --global alias.ci 'commit -v' $ git ci
Oh, so nice.
Happy gitting!
autoqa-devel@lists.fedorahosted.org