気軽に楽しくプログラムと遊ぶ

自分が興味があってためになるかもって思う情報を提供しています。

git clone https://github.com〜とgit clone git@github.com〜の違い

git cloneにおけるclone対象リポジトリの設定方法の違いによりgit clone以下の指定方法が異なる。

https://github.com

下記を実行することでcloneする。

$ git clone https://github.com/user_account/project_name.git

git clone git@github.com(ssh 公開鍵暗号を用いる場合)

git cloneを実行するにはまず、鍵の作成、githubへの鍵の設定が必要。

鍵の作成

以下を実行すると

$ ssh-keygen -t rsa

下記の鍵が生成される。

公開鍵のクリップボードへのコピー(Macの場合)

$ pbcopy < ~/.ssh/id_rd_rsa.pub

githubへの鍵の設定

GitHubのページで「account settings」 -> 「SSH Keys」 のページを開く。

f:id:tamata78:20160103173554p:plain

key追加において、公開鍵 ~/.ssh/id_rsa.pub の中身を貼り付ける。

ssh接続の確認

$ ssh -T git@github.com

Warning: Permanently added the RSA host key for IP address 'XXX.XX.XXX.XXX' to the list of known hosts.
Hi tamata78! You've successfully authenticated, but GitHub does not provide shell access.

git cloneの実行

$ git clone git@github.com:user_account/project_name.git

参考URL

GitHubでssh接続する手順~公開鍵・秘密鍵の生成から~ - Qiita とあるエンジニアの備忘log: GitHub 覚え書き