Skip to content

Instantly share code, notes, and snippets.

@PadreSVK
Last active September 29, 2020 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PadreSVK/70af15aa8c398aed161e5f53aaaa6af1 to your computer and use it in GitHub Desktop.
Save PadreSVK/70af15aa8c398aed161e5f53aaaa6af1 to your computer and use it in GitHub Desktop.
Git configuration for more organizations/git profiles
[user]
email = patrik.svikruha@gmail.com
name = Patrik Svikruha
[credential]
helper = wincred
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
[core]
editor = code --wait
[merge]
tool = bc
[mergetool "bc"]
path = C:/Program Files/Beyond Compare 4/BCompare.exe
[mergetool]
keepBackup = false
[difftool "sourcetree"]
cmd = '' \"$LOCAL\" \"$REMOTE\"
[mergetool "sourcetree"]
cmd = "'' "
trustExitCode = true
[includeIf "gitdir:~/MyOtherOrganization/"]
path = .gitconfig-MyOtherOrganization
[user]
email = patrik.svikruha@myotherorganization.com

Add files to

  • %UserProfile%/.gitconfig-MyOtherOrganization
  • %UserProfile%/.gitconfig
  • only if you want to use git precommit hook %UserProfile%\.git\templates\hooks\pre-commit
#!/bin/sh
PWD=`pwd`
if [[ $PWD == *"MyOtherOrganization"* ]]
then
EMAIL=$(git config user.email)
if [[ $EMAIL == *"myotherorganization
.cz"* ]]
then
echo "";
else
echo "Wrong email for myotherorganization project";
echo "run:"
echo ' git config user.email "svikruha@myotherorganization.cz"'
echo ''
exit 1;
fi;
elif [[ $PWD == *"\PersonalProjects"* ]]
then
EMAIL=$(git config user.email)
if [[ $EMAIL == *"gmail.com"* ]]
then
echo "";
else
echo "Wrong email for personal project";
echo "run:"
echo ' git config user.email "patrik.svikruha@gmail.com"'
echo ''
exit 1;
fi;
fi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment