Show HN: Switch Git Users CLI
github.com
Show HN: Switch Git Users CLI
1–10 of 61 posts
Re: Show HN: Switch Git Users CLI
#2So I made this as a sugar for git config user.email whatever@gmail.com
Re: Show HN: Switch Git Users CLI
#3Re: Show HN: Switch Git Users CLI
#4Re: Show HN: Switch Git Users CLI
#5Author here! I'm a freelancer working for multiple agencies at the moment. And One of the requirements was that I use the agency email for all commits. So I made this as a sugar for git config user.email whatever@gmail.com
Is a lot easier then what you came up with.
Re: Show HN: Switch Git Users CLI
#6What I have been doing by hand for some time is putting code for different customers in different directories and having a conditional in `~/.gitconfig` to determine what config applies there:
[includeIf "gitdir:~/projects-private/**"]
path = ./.gitconfig-private
[includeIf "gitdir:~/projects-client/**"]
path = ./.gitconfig-work
Then in .gitconfig-private or .gitconfig-work I have all the usual gitconfig settings that apply, for example the [user] section...Switching to the right directory thus automatically changes the settings.
Re: Show HN: Switch Git Users CLI
#7This is a great looking tool. What I have been doing by hand for some time is putting code for different customers in different directories and having a conditional in `~/.gitconfig` to determine what config applies there: [includeIf "gitdir:~/projects-private/**"] path = ./.gitconfig-private [includeIf "gitdir:~/projects-client/**"] path = ./.gitconfig-work Then in .gitconfig-private or .gitconfig-work I have all th…
However, your .gitconfig setup is (for me) way nicer as I already have things split up by GitHub organization, and now my identity can change without having to do anything at all.
So thanks for sharing that, had no idea it was possible.
Re: Show HN: Switch Git Users CLI
#8 #!/usr/bin/env zsh
case $1 in
foo)
git config user.name 'John Doe'
git config user.email john@example.com
git config user.signingKey 0xFFFFFFFF
;;
bar)
git config user.name 'Jane Doe'
git config user.email jane@example.com
git config user.signingKey 0xEEEEEEEE
;;
baz)
git config user.name 'My Dog'
git config user.email dog@example.com
git config user.signingKey 0xDDDDDDDD
;;
*)
echo "usage: git-user foo|bar|baz" >&2
exit 1
;;
esac
Done.Btw probably want to add signingKey support.