Live data from Hacker News

How I configure my Git identities

benji.dog

91–100 of 113 posts

Re: How I configure my Git identities

#91
post #42

One even-better approach IMHO Just keep a .gitconfig in your HOME with aliases for your identities. Then just after initializing/cloning the repo do git config-company or git config-personal er453r@r7:~$ cat ~/.gitconfig [user] useConfigOnly = true [alias] config-personal = !echo CONFIG-PERSONAL && \ git config --local user.email 'personal@email.com' && \ git config --local user.name 'personal' && \ git config --loca…

How would you do the initial clone without the correct ssh config to begin with? I think the benefit of the article's method is that any clone from their org will just work .

You are right - that first clone has to be manually preceded by GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_personal" - but after this you just configure the repo and forget about it.

I just like this workflow better since it is totally directory/remote agnostic (compared to the article).

Just use whatever suits you best :)

Re: How I configure my Git identities

#92
post #79
post #60

Earlier quoted context omitted.

Using a "personal machine for work" is a very wide gamut of situations (eg. at one remote-first company, we were expected to provide our own laptops, and got extra money every 2-3 years to buy a new one, but they were always our "personal" laptops even if the company contributed to paying them off; or what if you are a temporary contractor; or...). Care to elaborate in what circumstances is it a problem and why? Edit…

> Care to elaborate in what circumstances is using a "personal machine for work" a problem and why? When you stop working for an employer/customer and you are legally required to purge all files. Having everything work-related on a dedicated machine makes purging all files very easy. Not having everything work-related on a dedicated machine makes purging all files questionable.

[deleted]

Re: How I configure my Git identities

#93
Somewhat annoying, that the configuration is spread out across 2 config files of 2 separate programs (git and ssh) and that the `insteadOf` `url` must match the `Host` in `.ssh/config`, which leaves a lot of room for mistakes and is fiddly, but at least this method works well!

Edit: Hmm it seems to ask me over and over again for my password for a key at every pull or push. Maybe this method somehow disables memorizing the SSH identity?

Re: How I configure my Git identities

#94
post #73
post #67

Earlier quoted context omitted.

- Endpoint monitoring software may compromise more than it strictly needs to; - If you're a contractor, risk of leaking other clients' assets (running `tree` in the wrong folder while screensharing or more subtle variations); - Shredder policy, done with the work = destroy hardware (though I don't think companies with shredder policy would incentivise personal laptops, you never know)

If it's a personal laptop, I would assume there is no "endpoint monitoring software" installed. When it comes to "assets", companies make a big fuss about leaking them, but in reality, it's totally irrelevant. I.e. witness Windows OS source code being leaked: Microsoft wasn't affected at all. Leaking short/mid-term plans would probably have a bigger effect (abuse on the stock market, beating a competitor to the marke…

You would assume wrong, many (asshat) employers require them, so much that I actually have to screen that kind of sillyness when interviewing. Works a treat to filter out toxic workplaces, but exists nontheless.

As for leaking assets, maybe it does not affect the company at large, but that literally does not matter for this discussion. It will definitely affect your relationship, most often negatively.

And in any case, my usage of assets was clearly general, substitute the example for "clicking on the wrong stored tab while screensharing" can just as well lead you to leaking a plan.

Re: How I configure my Git identities

#96
I prefer to split work and personal repos into ~/dev for work and ~/src for personal.

  # file ~/.gitconfig
  [includeIf "gitdir:~/src/"]
  path = /Users/metabeard/.config/git/.gitconfig-personal
  [includeIf "gitdir:~/dev/"]
  path = /Users/metabeard/.config/git/.gitconfig-work
and

  # file .config/git/.gitconfig-personal and .config/git/.gitconfig-work
  # both are very similar with different email and signingkey
  [user]
    name = Meta Beard
    email = email@metabeard.me
    signingkey = ssh-rsa xxx==

  [gpg]
    format = ssh

  [gpg "ssh"]
    program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign"

  [commit]
    gpgsign = true

Re: How I configure my Git identities

#97

I prefer to split work and personal repos into ~/dev for work and ~/src for personal. # file ~/.gitconfig [includeIf "gitdir:~/src/"] path = /Users/metabeard/.config/git/.gitconfig-personal [includeIf "gitdir:~/dev/"] path = /Users/metabeard/.config/git/.gitconfig-work and # file .config/git/.gitconfig-personal and .config/git/.gitconfig-work # both are very similar with different email and signingkey [user] name = M…

[deleted]

Re: How I configure my Git identities

#98
post #91

Earlier quoted context omitted.

How would you do the initial clone without the correct ssh config to begin with? I think the benefit of the article's method is that any clone from their org will just work .

You are right - that first clone has to be manually preceded by GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_personal" - but after this you just configure the repo and forget about it. I just like this workflow better since it is totally directory/remote agnostic (compared to the article). Just use whatever suits you best :)

The same exact config you'd have to replicate for the OP's solution is what you'd have to replicate as well. It also means your config is semi-copied into every repo instead of being centrally managed. This is like the worst of all options, idgi.

I'm sorry, I don't want to be mean but this has got to be the worst way Ive seen someone try to solve this. I want to cry skimming it. Why would anyone do this and think it's simpler? Wew, gotta just leave this one alone.

Re: How I configure my Git identities

#99
Eh, if I need a different identity[1], I just use a different identity[2] (ideally different machine or host when feasible).

I'm not a fan of mixing identities, like for example mixing a personal identity[2] with a work identity[1].

[1]: Git.

[2]: OS user.

Re: How I configure my Git identities

#100
post #91

Earlier quoted context omitted.

How would you do the initial clone without the correct ssh config to begin with? I think the benefit of the article's method is that any clone from their org will just work .

You are right - that first clone has to be manually preceded by GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_personal" - but after this you just configure the repo and forget about it. I just like this workflow better since it is totally directory/remote agnostic (compared to the article). Just use whatever suits you best :)

You don't need to specify your key file like that if you've got your keys loaded into an SSH agent. Or even better, IMO: use 1Password or similar that can both store your keys securely _and_ can be used directly as an SSH agent. That way, your SSH keys never need to be stored on disk in the first place.
Post reply on HN