It's described nicely in documentation gitconfig includeIf docs. This is achieved by ordering "includeIf" clauses in your $HOME/.gitconfig and having trailing slash in glob patterns, which results in adding ** at the end. configurations are evaluated from more generic to more specific one. And another name/email also for commits, not only rsa key. Whenever I run any git command in ~/idea/org-1 directory or its sub-dirs, then it picks up my org-1 specific config and uses my_org1_account_id_rsa for ssh. And in that dir I create a ".gitconfig" file, like: $HOME/idea/org-1/.gitconfigĮmail = "ssh -i ~/.ssh/my_org1_account_id_rsa" $HOME/.gitconfigĮmail = "ssh -i ~/.ssh/my_public_account_id_rsa"Īnd if I need to override key and user details for some projects, then I keep them in the same dir. It uses directory structure instead, and per-dir-subtree configurations. It doesn't matter whether it's github, bitbucket, or whatever this setup is not touching ssh client config, neither it uses hosts as selectors for configuration. This is my setup for multiple accounts, each using separate rsa key. Use the ~/.ssh/config file as suggested in other answers in order to specify the location of your private key, e.g. Note: GIT_SSH is available since v0.99.4 (2005). They will create a file named ssh, make it executable, and (indirectly) execute it. $ GIT_TRACE=1 GIT_SSH='./ssh' git clone The above lines are shell (terminal) command lines which you should paste into your terminal. ![]() ![]() Pass the ssh arguments by using the GIT_SSH environment variable to specify alternate ssh binary.įor example: $ echo 'ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKe圜hecking=no $*' > ssh Git clone can type this all on one line - ignore $ and leave out the \. Pass the ssh arguments by using the GIT_SSH_COMMAND environment variableįor example: $ GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKe圜hecking=no' \ You can use ssh-agent to temporarily authorize your private key.įor example: $ ssh-agent sh -c 'ssh-add ~/.ssh/id_rsa git fetch 2: GIT_SSH_COMMAND However, there are still a few ways to achieve your goal: Option 1: ssh-agent There is no direct way to tell git which private key to use, because it relies on ssh for repository authentication.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |