githubことはじめ<複数ユーザでpushするまでの初期設定>
うっかり忘れてしまう事が多いのでシンプルに書き留めておきます。よく考えたらレシピにするなりしておけば良かったです。
- gitインストール
- 鍵を準備する
- 作成した鍵をgit上のアカウントに紐付ける
- git cloneしてみる
- git pushしてみる
- git fetch/mergeして更新を追従する
gitインストール
特にバージョンにこだわりがなければ、そのままyumでインストールでOKです。
yum install git
鍵を準備する
新規のサーバで鍵ファイルがない場合、github用の鍵を新しく作る場合です。今回は全てデフォルトで作成しています。
$ ls /home/komei/.ssh authorized_keys $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/komei/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/komei/.ssh/id_rsa. Your public key has been saved in /home/komei/.ssh/id_rsa.pub. The key fingerprint is: The key's randomart image is: +--[ RSA 2048]----+
作成した鍵をgit上のアカウントに紐付ける
以下、公式ヘルプが参考になります。
Step 3: Add your SSH key to your account
https://help.github.com/articles/generating-ssh-keys/
簡単に書くとユーザの設定画面からssh keyを選択し公開鍵を貼付けてください。
git cloneしてみる
ここではhttps://ではなくgit://で試してみます。
$ git clone git://github.com/<username>/<repository>.git
git pushしてみる
何か更新してみます。その後、origin/masterにpushします。リモートサーバのmasterブランチを更新しています。
$ git add . $ git status $ git commit -m "<commit>" $ git push origin master
git fetch/mergeして更新を追従する
上記で問題なくpushできたら今度は別のユーザが更新した内容を反映させてみましょう。
名前は何でもいいですが、慣例ではupstreamとして設定をするようですので、それに従います。
git remote add upstream git@github.com/<username>/<repository>.git git fetch upstream git merge upstream/master
更新が反映されましたか?
他には以下のエラーが出たらメールアドレスとユーザ名を設定して対処いましょう。
fatal: empty ident name git config --global user.email "<mail-address>" git config --global user.name "<username>"
よく使うのでメモです。取り急ぎ、pullリクエストではなくpushとfetch/mergeをメモしておきます。
シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。
GitHub実践入門 ~Pull Requestによる開発の変革 (WEB+DB PRESS plus)
- 作者: 大塚弘記
- 出版社/メーカー: 技術評論社
- 発売日: 2014/03/20
- メディア: 単行本(ソフトカバー)
- この商品を含むブログ (14件) を見る
- 作者: Junio C Hamano,大塚弘記,川口耕介,kana,大竹智也(tomoya),尾藤正人,WEB+DB PRESS編集部
- 出版社/メーカー: 技術評論社
- 発売日: 2013/04/10
- メディア: 大型本
- クリック: 1回
- この商品を含むブログ (11件) を見る