Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomykaira/c900e5f76cd2b3a1552d9665e2a40dc4 to your computer and use it in GitHub Desktop.
Save tomykaira/c900e5f76cd2b3a1552d9665e2a40dc4 to your computer and use it in GitHub Desktop.
Memo, how to sync github repo as IDEA setting repository.

Official document: https://www.jetbrains.com/help/idea/settings-tools-settings-repository.html

Problem

With Personal Access Token (PAT), as far as I tried, it is impossible to push changes to private repos. Therefore it is impossible to use https:// git url as sync rpeo.

With git@github.com URL, jgit (jsch) emits authorization errors on sync even if the SSH pub key is added to your Github account. This is because jgsch does not support OpenSSH format ssh private keys.

Solution

Create RSA format PEM key file.

cp id_rsa id_rsa.pem
# This command OVERWRITES the specified file. Copy the key beforehand.
ssh-keygen -p -f id_rsa.pem -m pem

Add dummy host to ~/.ssh/config to use the above PEM key for access from jsch.

Host github-jgit
  Hostname github.com
  User git
  IdentityFile C:\Users\YOU\.ssh\id_rsa.pem

Specify the proxy hostname when setting repo to IDEA.

git@github.com:YOU/idea-setting-sync.git
↓
git@github-jgit:YOU/idea-setting-sync.git

For this method, PAT is not required at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment