Automatically keep your local git repos clean

Posted by kerry on Gooder Code See other posts from Gooder Code or by kerry
Published on Thu, 24 Oct 2013 15:37:59 +0000 Indexed on 2013/10/24 16:04 UTC
Read the original article Hit count: 212

Filed under:
|

Most developers using git are probably aware of a command ‘git gc’ that has to be run from time to time when you notice your git commands are running a little slow. This command cleans up your git repo and makes sure everything is nice and tidy. If you have not run this command lately, you will notice a huge performance increase in your git commands after running. It’s a bit annoying to have to run this command when you notice that your git performance is suffering. The command also takes a while if you have not run it recently. With this in mind, I decided to create a method to automatically run this command from time to time. So I decided to overload cd similar to how rvm does. All you have to do is paste the method in your .profile file and it will run the command every time you enter a directory with a git repo. You’ll notice a little pause when entering the directory, it’s not insufferable but if you would prefer, you can add an & to the end of the command to have it run in the background. I chose the pause over the pid output of the background command.

Here it is in all it’s glory.

© Gooder Code or respective owner

Related posts about Developer Tools

Related posts about git