Branchout / branchout

A manyrepo management tool to allow for local monorepo projecting while keeping everything in distinct repositories
Apache License 2.0
9 stars 2 forks source link

Support use of a particular SSH config file, rather than the user-wide default. #73

Open fredcooke opened 3 years ago

fredcooke commented 3 years ago

git config core.sshCommand "ssh -F ~/.ssh/config-some-specific-profile-for-this-particular-project-set-on-github"

Needed on any machine operating on github repos under different identities.

fredcooke commented 3 years ago

In particular, this is needed for fresh clones, so perhaps it could be integrated at the same time as the other issue #21 for emails. Instead of a clone, maybe do:

git init <dir>
cd <dir>
git config email
git config ssh command
git remote add origin <url>
git fetch 
git checkout default branch

Or some other approach.

stickycode commented 3 years ago

Good idea so the property would need to be set in the config and automatically set in the repositories by branchout, that same thing needs to happen for the author email.

fredcooke commented 3 years ago

This can be worked around by exporting GIT_SSH_COMMAND rather than relying on one set in config - necessary for an initial clone AFAICT. Maybe that's the way to go? Just have it configured and put it in the env before running the Git commands? Not sure if it would end up in the cloned repo or still need setting, separately. Let me check that.... I can't easily check it as I ran another command that does do the setup after the initial clone. But I suspect it's not set after a clone with the variable set like that.

fredcooke commented 3 years ago

There's another way to skin this cat provided you're all in on branchout:

Use .ssh/config to configure things like this:

Host org.github
  User git
  Hostname github.com
  identiityFile ~/.ssh/org_rsa

Then do the branchout init/clone like this: org.github:bo_repo.git and it'll use that config, do this differently for each one and they can all coexist. Only the initial clone might require something like:

GIT_SSH_COMMAND="whatever" git clone git@github.com:repo.git and then edit .git/config to suit.