#!/bin/bash # Simple script to switch between git global config & credential store # Assuming you are storing your config in "$HOME/.gitconfig-{profile_name}" # and credential in "$HOME/.git-credentials-{profile_name}", switch to it by calling # git-switch {profile_name} if [ "$#" -ne 1 ] then echo "usage: git-switch {profile}" else profile=$1 config_file="$HOME/.gitconfig-$profile" cred_file="$HOME/.git-credentials-$profile" if [[ -f "$config_file" && -f "$cred_file" ]] then rm $HOME/.gitconfig && cp $config_file $HOME/.gitconfig rm $HOME/.git-credentials && cp $cred_file $HOME/.git-credentials else [ ! -f "$config_file" ] && echo "$config_file does not exist" [ ! -f "$cred_file" ] && echo "$cred_file does not exist" fi fi