Git Switch

July 22nd, 2010

I have a need to change my git profile depending on what I'm working on. I created a simple script that I could run in the shell to switch between my profiles.

If you put this script in your PATH, you can then run git switch place, where place is the profile you would like to use. In the script above, place1 is your first profile and anything else is the second profile. This allows you to run git switch, which just switches to the last, default profile.

The magic of git is that if you run git something, it looks for the command git-something in your path and runs it. If you save the above script as git-switch in your PATH and make it executable, you can execute the command as if it were apart of your git tool chain.

blog comments powered by Disqus