GitHubリポジトリの備忘録

新しいPCでcloneしてPushするまで

自分で所有するGitHubのリポジトリをローカルにcloneしてPushするまでの手順。

①秘密鍵をPC側に置く

アクセス権限を設定する。

②~/.ssh/configを編集

以下を追加。

Host github.com
    HostName github.com
    User git
    Port 22
    IdentityFile ~/.ssh/id_rsa_github
    TCPKeepAlive yes
    IdentitiesOnly yes

③SSHの接続テスト

下記のコマンドを実行

ssh -T git@github.com

下記のメッセージが表示されればOK

Hi <アカウント名>! You've successfully authenticated, but GitHub does not provide shell access.

④git cloneする。

下記のようにコマンドを実行

git clone git@github.com:<アカウント名>/<リポジトリ名>.git

⑤メールアドレスと名前を登録

git config --global user.email "xxx@yyy.zzz"
git config --global user.name "hoge hoge"

⑥後は普通に使えばいい。

ファイルを編集したら

git add .
git commit -m "message"
git push

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です