Archive for December, 2009

git housekeeping tasks

Saturday, December 26th, 2009

Every once in a while, it is necessary to perform a few housekeeping tasks to keep your git repository clean and efficient :

delete unused local branches

git branch -a

git branch -D unused_local_branch

delete unused remote branches

git push origin :unused_remote_branch

delete unused remote-tracking branches

If you use a shared-repository approach (several people have commit access to the same remote git repository), it will happen that someone else deletes a branch on the remote repository. Git does not automatically delete your local remote-tracking branches. To do so, it is necessary to :

git remote prune origin

clean-up unreachable commit objects

git prune

efficiently pack the repository objects

git gc –aggressive

That’s it :)