Author 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
https://git-scm.com/docs/git-config#_conditional_includes Is a lot easier then what you came up with.
Show HN: Switch Git Users CLI
11–20 of 61 posts
Re: Show HN: Switch Git Users CLI
#12Re: Show HN: Switch Git Users CLI
#13 git config --global --unset user.name
git config --global --unset user.email
git config --global --unset user.signingkey
git config --global user.useConfigOnly true
git config --global user..name ""
git config --global user..email ""
git config --global alias.identity '! git config user.name "$(git config user.$1.name)"; git config user.email "$(git config user.$1.email)"; :'
So given that I have created two users, e.g. personal and work I run: git identity work
in repos that need the work name/e-mail, and git identity personal
in the ones that are private.Re: Show HN: Switch Git Users CLI
#14This 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…
I'd still think the cli could be useful in some situations. but I agree with others about how big this had to be because I used node.
Re: Show HN: Switch Git Users CLI
#15A 1000 line YARN lock file for something that would be roughly 20 lines of bash is amazing and terrifying at the same time.
Re: Show HN: Switch Git Users CLI
#16A 1000 line YARN lock file for something that would be roughly 20 lines of bash is amazing and terrifying at the same time.
Re: Show HN: Switch Git Users CLI
#17Author 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
Re: Show HN: Switch Git Users CLI
#18What's the point of writing this simple tool in js? I'd like to use it but I don't have npm everywhere (and I don't want to grab a huge tree of dependencies just for editing a couple of lines on a text file...)
Re: Show HN: Switch Git Users CLI
#19I found this user management strategy somewhere, and it's been working great for me: git config --global --unset user.name git config --global --unset user.email git config --global --unset user.signingkey git config --global user.useConfigOnly true git config --global user. .name " " git config --global user. .email " " git config --global alias.identity '! git config user.name "$(git config user.$1.name)"; git conf…
Re: Show HN: Switch Git Users CLI
#20This 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…
Thanks for sharing this. This was what I was missing. Should've done proper research before building. I'd still think the cli could be useful in some situations. but I agree with others about how big this had to be because I used node.