Jaigouk.Kim
Jaigouk.Kim

Let the ideas flow.

Jaigouk KIm
Author

Share


Tags


Switching between git profiles

Maintaining multiple profiles are pain in the ass. Sometimes, it's easy to switch and commit your codes and push. So, I have my own setup to prevent a situation like that.

You can automate switching users based on directory.

For zsh,

precmd_functions=(switch_git_user)
switch_git_user() {
  if [[ $PWD == "$HOME/user/git_repo" ]]; then
    $HOME/bin/switch hack

    cat ~/.gitconfig
  fi
}

with the switch script and precmd above, I can just switch git profile automatically.

Jaigouk KIm
Author

Jaigouk KIm

View Comments