The most frustrating thing with Git is that I make commits to repositories with wrong name and email. All the time! To solve this I have such entry in global Git config: Pilkauskas

Which simply says that I need my name to stay the same across all repositories, but I want my email to vary according organization. To solve this, I’ve written a small script.


ORIGIN=$(git config --get remote.origin.url)

if [[ $ORIGIN == *"wix"* ]]
  echo "Setting user info to Wix for the project"
  git config
  echo "Setting user info to personal for the project"
  git config

This script tries to detect organization of the repo I work on (I am employed by and picks email according to it. After I have freshly cloned repository, first commit fails if I haven’t run this script.