Githubは更新のConflictが起こらないように気を付ける必要があり、githubでCloneしたレポジトリをMasterにちゃんと追従する方法を記載します。Oraganaizationを使用してますが、基本的に操作は一緒です。
クライアント
Origin/Masterでは通常通り「add」「commit」「push」をします。
[user@localhost app]$ git add README.md
[user@localhost app]$ git commit -m "modify api tree => table"
[master d4774c3] modify api tree => table
1 files changed, 27 insertions(+), 42 deletions(-)
[user@localhost app]$ git push -u origin master
Enter passphrase for key '/home/user/.ssh/github_organaize':
Counting objects: 5, done.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 605 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To git@github-organaize:Organaization/repo.git
8824155..d4774c3 master -> master
Branch master set up to track remote branch master from origin.
サーバ
pushした内容をサーバにCloneします。この環境では./ssh/configを使用してますので、適宜変更してください。
git clone git@github-organaize:Organaization/repo.git
このサーバ側はoriginではなく「upstream」として登録します。
[server@localhost app]$ git remote add upstream git@github-organaize:Organaization/repo.git
あとはfetchとmergeをして完了です。Masterの変更点が反映されていることを確認してください。
fetch後に「git branch -a」で確認するとupstream/masterが追記されていました。
[server@localhost app]$ git fetch upstream
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 5), reused 6 (delta 2)
Unpacking objects: 100% (9/9), done.
From github-organaize:Organaization/repo
10f1940..d4774c3 master -> upstream/master
[server@localhost app]$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/upstream/master
git branch -aで問題なく追加されているようであれば、そのままmergeしてください。
[server@localhost app]$ git merge upstream/master
Updating 10f1940..d4774c3
Fast-forward
README.md | 71 +++++++++++++++++++++---------------------------------------
1 files changed, 25 insertions(+), 46 deletions(-)
以上、簡単ですが方法だけメモしておきます。