dvratil10 minutes ago
I used to have a git post-checkout hook that set the repo identity based on the repo origin url [0] on checkout - maybe there's some post-clone hook these days, but 10 years ago when I wrote it there was only post-checkout hook.

[0] https://www.dvratil.cz/2015/12/git-trick-%23628-automaticall...

Kwpolska1 hour ago
Solving the problem of having a personal and a work GitHub account is really trivial without any extra tools. All you need is a dedicated SSH key for that GitHub account. (And why would you have a password for a ssh key on your personal machine?)

~/.ssh/config

    Host github.com-work
     HostName github.com
     User git
     IdentityFile ~/.ssh/work_id_rsa
     IdentitiesOnly yes
~/.git/config

    [user]
    email = work@example.com

    [remote "origin"]
    url = github.com-work:Work/Widget.git
embedding-shape1 hour ago
Which works for a while, until you have a bunch of projects under various identities.

In my main ~/.gitconfig I have:

  [includeIf "gitdir:/home/user/projects/embedding-shapes/"]
  path = /home/user/.gitconfig-embedding-shapes
Where basically `projects/` follow GitHub naming with $user/$repo, so I set the git identity based on all projects within that user, rather than repo-by-repo which would get cumbersome fast.

Then you just make sure you're in the right directory :)

rgoulter1 hour ago
For the use case of "use different accounts / configs for different directories", git's config has includeIf.
7777777phil1 hour ago
Lovley, was looking for exactly that for some time. Will definitely try it, thanks for sharing!