10 comments

  • teeray0 minutes ago
    [delayed]
  • sigmonsays5 minutes ago
    Feel free to have your own workflow but git already addresses this tools entire purpose with includeIf.<p>what does this address that includeIf does not?
  • Kwpolska5 hours 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?)<p>~&#x2F;.ssh&#x2F;config<p><pre><code> Host github.com-work HostName github.com User git IdentityFile ~&#x2F;.ssh&#x2F;work_id_rsa IdentitiesOnly yes </code></pre> ~&#x2F;.git&#x2F;config<p><pre><code> [user] email = work@example.com [remote &quot;origin&quot;] url = github.com-work:Work&#x2F;Widget.git</code></pre>
    • embedding-shape4 hours ago
      Which works for a while, until you have a bunch of projects under various identities.<p>In my main ~&#x2F;.gitconfig I have:<p><pre><code> [includeIf &quot;gitdir:&#x2F;home&#x2F;user&#x2F;projects&#x2F;embedding-shapes&#x2F;&quot;] path = &#x2F;home&#x2F;user&#x2F;.gitconfig-embedding-shapes </code></pre> Where basically `projects&#x2F;` follow GitHub naming with $user&#x2F;$repo, so I set the git identity based on all projects within that user, rather than repo-by-repo which would get cumbersome fast.<p>Then you just make sure you&#x27;re in the right directory :)
      • beaker522 hours ago
        This. I’ve seen so many tools solving problems that already have solutions lately because LLMs allow people to run off and “fix” the problem their way before they can a chance to discover existing, more appropriate solutions.<p>The next step of this problem space is: “when I’m working on project X, I often forget to change my GitHub user with Gitas” so now they need direnv or something to switch it for them. The original solution foresaw this - so is far more complete that Gitas already _and_ built into git itself.<p>But, LLMs, so here we are, slowly drowning in a growing ocean of software built by the unaware.
      • accoil3 hours ago
        I use that approach. I also make sure to not set the [user] section in my main config (and only in the included files). That way if I&#x27;m operating outside of one of my user directories git commit fails due to having no user details.
    • OrderlyTiamat1 hour ago
      &gt; (And why would you have a password for a ssh key on your personal machine?)<p>You&#x27;re presumably joking? If not, could you elaborate?
      • PunchyHamster55 minutes ago
        well if you have encrypted storage and already need password to get to it, secondary password is of little value<p>Tho I prefer to just use hardware key for ssh
        • craftkiller22 minutes ago
          &gt; well if you have encrypted storage and already need password to get to it, secondary password is of little value<p>That&#x27;s only true when your machine is powered off. If an attacker manages to yank files from your disk while it is running, that ssh-key password is the difference between &quot;they stole my ssh key&quot; and &quot;they stole worthless random data&quot;.<p>&gt; use hardware key for ssh<p>That&#x27;s the real solution. I don&#x27;t understand why people still store ssh keys on disk when hardware keys are simple, easy, and significantly more secure.
        • rzzzt31 minutes ago
          ssh-agent will also be happy to provide the key to git after an initial unlock with the passphrase.
    • arccy3 hours ago
      If you don&#x27;t want to bother with directories or want to use https instead of ssh, you can do remote url based dispatch in your gitconfig:<p><pre><code> [credential &quot;https:&#x2F;&#x2F;github.com&#x2F;org1&quot;] useHttpPath = true helper = helper = &#x2F;path&#x2F;to&#x2F;auth.sh user1 [includeIf &quot;hasconfig:remote.*.url:https&#x2F;&#x2F;github.com&#x2F;org1&#x2F;**&quot;] path = user1.gitconfig ; set name &#x2F; email in user1.gitconfig </code></pre> where auth.sh is something that can produce the right token for the given user, e.g.<p><pre><code> #!&#x2F;bin&#x2F;bash echo &quot;username=$1&quot; echo &quot;password=$(gh auth token --user $1)&quot;</code></pre>
    • xn2 hours ago
      Are there any good reasons to use multiple GitHub user accounts? GitHub organization membership and permissions are well designed in my experience, negating the need for multiple user accounts.
      • StarlaAtNight1 hour ago
        Consultants or professional services folks will be working in their company’s GitHub account and several clients. Requires managing lots of git&#x2F;GitHub accounts
      • embedding-shape2 hours ago
        &gt; Are there any good reasons to use multiple GitHub user accounts?<p>Is there any good reasons not to separate what you work on into multiple GitHub accounts? Not to mention some people don&#x27;t want all their projects attached to one profile, some people also develop in their free-time, and don&#x27;t want to mix freetime&#x2F;work projects under the same user account, for multiple reasons.
      • jimmydoe1 hour ago
        A why not<p>B if you ever be in a company using the half baked GitHub hosted enterprise….
      • Hamuko58 minutes ago
        I use a pseudonym during my free time, so yes. Also my employer is requiring us to use company-specific GitHub accounts, so the decision is out of my hands anyway.
    • adithyassekhar1 hour ago
      Is this that dropbox moment again? Anyway on Windows I keep a separate work and personal profile and GitHub auth doesn&#x27;t go between them.
    • jimmydoe1 hour ago
      For Claude Code users:<p>- using alternative host is not supported when roaming between local and cloud, fix is to add another origin you don’t use but use GitHub.com url<p>- CC uses gh command, which still needs account switch, this can be solved by add the switch to CC hook.
  • eqvinox2 hours ago
    You can put [user] blocks in repos, i.e.<p><pre><code> &#x2F;some&#x2F;where $ head .git&#x2F;config [user] email = me@example.org name = My &#x27;nick&#x27; Name </code></pre> Doesn&#x27;t tie into your SSH key though, if you need that.
    • turbocon2 hours ago
      You can manage multiple ssh keys via your ssh config too. But this does seem to make things easier, I always end up fighting with this when I need to do it once every 3 years
  • sevensor2 hours ago
    Git<i>hub</i> account switching. A git account is not an idea that makes sense.
    • embedding-shape2 hours ago
      It&#x27;s actually about <i>git</i> account switching as far as I can tell, which does make sense, you can have multiple &quot;git&quot; users indeed. Maybe it&#x27;s the wording that is wrong? Read &quot;account&quot; as &quot;user&quot; and it might make more sense :)<p><pre><code> # in ~&#x2F;.gitconfig [includeIf &quot;gitdir:&#x2F;home&#x2F;user&#x2F;projects&#x2F;embedding-shapes&#x2F;&quot;] path = &#x2F;home&#x2F;user&#x2F;.gitconfig-embedding-shapes # in ~&#x2F;.gitconfig-embedding-shapes [user] name = embedding-shapes email = embedding-shapes@proton.me [core] sshCommand = ssh -i &#x2F;home&#x2F;user&#x2F;.ssh&#x2F;id_embedding-shapes </code></pre> That&#x27;s one of my git &quot;accounts&quot;, currently I have four in total, one being my &quot;real identity&quot;, other are pseudo-anonymous users.
      • sevensor1 hour ago
        Fair point. This makes much more sense when you make it about your git identity + ssh configuration.
    • christoph-heiss53 minutes ago
      Yeah. Unfortunately, just goes to show how many people think Git = Github.
  • PunchyHamster55 minutes ago
    you can have per repo and per directory git config via git conditional includes<p><pre><code> [includeIf &quot;hasconfig:remote.*.url:https:&#x2F;&#x2F;*.github.com&#x2F;**&quot;] path = &#x2F;home&#x2F;xani&#x2F;src&#x2F;gh&#x2F;.gitconfig</code></pre>
  • rgoulter5 hours ago
    For the use case of &quot;use different accounts &#x2F; configs for different directories&quot;, git&#x27;s config has includeIf.
  • dvratil3 hours 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&#x27;s some post-clone hook these days, but 10 years ago when I wrote it there was only post-checkout hook.<p>[0] <a href="https:&#x2F;&#x2F;www.dvratil.cz&#x2F;2015&#x2F;12&#x2F;git-trick-%23628-automatically-set-commit-author-based-on-repo-url&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.dvratil.cz&#x2F;2015&#x2F;12&#x2F;git-trick-%23628-automaticall...</a>
  • 7777777phil5 hours ago
    Lovley, was looking for exactly that for some time. Will definitely try it, thanks for sharing!
  • aditya24raj2 hours ago
    [dead]