← Home

Git общий ключ

By Брендель В. М.

Можно сделать общий ключ на все машины.

Генерим пару открытый ключ/приватный. Открытый отдаем серверу Git, приватный секурно передаем на все свои локальные машины в папку .ssh.

Есть нюанс: придется дополнительно сказать git, какой ключ использовать для какого репозитория.

В линуксе:

~/.ssh/config

Host your.hostname.com Hostname github.com User git IdentityFile ~/.ssh/special_id_rsa

В винде:

Открываем от админа C:\Program Files\Git\etc\ssh\ssh_config

Host your.hostname.com

Identityfile ~/.ssh/special_id_rsa

Дополнительно можно заставить git пушить сразу в два репозитория

Sometimes you need to keep two upstreams in sync with eachother. For example, you might need to both push to your testing environment and your GitHub repo at the same time. In order to do this simultaneously in one git command, here's a little trick to add multiple push URLs to a single remote.

Once you have a remote set up for one of your upstreams, run these commands with:

git remote set-url --add --push [remote] [original repo URL] git remote set-url --add --push [remote] [second repo URL] Once set up, git remote -v should show two (push) URLs and one (fetch) URL. Something like this:

$ git remote -v origin git@github.com:bjmiller121/original-repo.git (fetch) origin git@github.com:bjmiller121/original-repo.git (push) origin git@github.com:bjmiller121/second-repo.git (push) Now, pushing to this remote will push to both upstreams simultaneiously. Fetch and pull from this remote will still pull from the original repo only.

Tip: If you always want to push to both upstreams simultaneously, you might want to use the origin remote. If you only sometimes want to push to both, you might use a remote name like both to indicate that it will push to multiple repos.

view rawmultiple-push-urls.md hosted with ❤ by GitHub