[Git] Fork/Clone した手元リポジトリに開発中の更新を取り込む
fetch/merge ぐせをつけるという考え方の実践として、具体的にはこんな感じかなという手続きを試してみた。
[markdown]
## git pull を使わずに、fetch/merge ぐせをつける
fetch / merge だと、確かに分かりやすい気がする。
> * [Git pullを使うべきでない3つの理由 – DQNEO起業日記](http://dqn.sakusakutto.jp/2012/11/git_pull.html)
> * [git – fetch と pullの違い – Qiita [キータ]](http://qiita.com/y42sora/items/e082d64f3f8b424e9b7d)
ただ、ぼっち開発なのでどう試すかなと思っていた。
ということで、こちらを参考にGitHubで公開されているもので試してみよう。
> * [GitHubでFork/cloneしたリポジトリを本家リポジトリに追従する – Qiita [キータ]](http://qiita.com/xtetsuji/items/555a1ef19ed21ee42873)
## remote add
本家のリポジトリをremoteに追加する。
“`
% git remote add upstream git@github.com:feibeck/application.ini.git
% git remote -v
origin git@github.com:DriftwoodJP/application.ini.git (fetch)
origin git@github.com:DriftwoodJP/application.ini.git (push)
upstream git@github.com:feibeck/application.ini.git (fetch)
upstream git@github.com:feibeck/application.ini.git (push)
“`
## fetch
fetchしてくる。
“`
% git fetch upstream
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 8 (delta 2), reused 7 (delta 1)
Unpacking objects: 100% (8/8), done.
From github.com:feibeck/application.ini
* [new branch] master -> upstream/master
“`
## diff
変更を確認する。
(下記はmerge後に試した出力だったはず。次回試す。)
“`
% git diff upstream/master
diff –git a/application.ini b/application.ini
index 01dc575..bc54bb5 100755
— a/application.ini
+++ b/application.ini
@@ -503,6 +503,7 @@
;
; resources.mail.transport.type = “smtp”
; resources.mail.transport.host =
+; resources.mail.transport.port =
; resources.mail.transport.auth = ‘crammd5’ ; ‘crammd5’, ‘login’ or ‘plain’
; resources.mail.transport.username =
“`
## merge
本家リポジトリを取り込む。
“`
% git merge upstream/master
Auto-merging application.ini
Merge made by the ‘recursive’ strategy.
application.ini | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
“`
## push
自分で更新した手元リポジトリを含めてpushする。
“`
% git push origin master
Counting objects: 15, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.54 KiB | 0 bytes/s, done.
Total 11 (delta 3), reused 0 (delta 0)
To git@github.com:DriftwoodJP/application.ini.git
59fd80b..8459976 master -> master
“`
こんな理解で良かったでしょうか。
また試す。
[/markdown]