Live data from Hacker News

Show HN: Switch Git Users CLI

github.com

21–30 of 61 posts

Re: Show HN: Switch Git Users CLI

#23
post #3

A 1000 line YARN lock file for something that would be roughly 20 lines of bash is amazing and terrifying at the same time.

> roughly 20 lines of bash

various permutations of which were posted an hour ago and are currently higher than this comment, so I’m confused why multiple people asked to see them ~30½ minutes ago

Re: Show HN: Switch Git Users CLI

#24
post #13

I 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…

I've been doing the same, this it's pretty good IMO.

Re: Show HN: Switch Git Users CLI

#26
post #23
post #3

A 1000 line YARN lock file for something that would be roughly 20 lines of bash is amazing and terrifying at the same time.

> roughly 20 lines of bash various permutations of which were posted an hour ago and are currently higher than this comment, so I’m confused why multiple people asked to see them ~30½ minutes ago

I asked because none of the posted permutations offer the same feature set. Specifically, the nice thing about this utility (and reason for the dependencies) is interactive adding and selecting of identities. If this can replicated in bash, I am legitimately interested in seeing it, 20 lines or not.

Re: Show HN: Switch Git Users CLI

#27
post #13

I 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…

I also appreciate using `git whoami` to check the current identity settings:

    $ git whoami 
    GIT_COMMITTER_IDENT=Mel Smith 
    GIT_AUTHOR_IDENT=Mel Smith 
`whoami` can be implemented via a simple alias:

    git config --global alias.whoami = "! git var -l | grep '^GIT_.*_IDENT'"

Re: Show HN: Switch Git Users CLI

#28
post #18

What'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...)

I suspect it was written in JS because that was the author’s language of choice. There are lots of ways to manage git identities and this seems like a decent utility for web devs who already have node installed and don’t care to manually edit config files.

Of course, but my point is that these kind of tools are of general interest, and most programmers are not web developers.

Re: Show HN: Switch Git Users CLI

#29
post #6

This 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…

This is the approach that works very well for me. Especially since I keep my repos cloned into a directory structure inspired by "go get" using https://github.com/grdl/git-get

Re: Show HN: Switch Git Users CLI

#30
post #26
post #23

Earlier quoted context omitted.

> roughly 20 lines of bash various permutations of which were posted an hour ago and are currently higher than this comment, so I’m confused why multiple people asked to see them ~30½ minutes ago

I asked because none of the posted permutations offer the same feature set. Specifically, the nice thing about this utility (and reason for the dependencies) is interactive adding and selecting of identities. If this can replicated in bash, I am legitimately interested in seeing it, 20 lines or not.

Implement the `git identity` portion listed earlier with a `identity-list` utilizing `git config --get-regexp`. If you need interactivity you can tie it together with fzf and some awk.
Post reply on HN