R.A. Epigonos et al.

[git] 読み取り専用レポジトリから変更をマージして読み書きレポジトリにpushする。

例えば、githubでforkすると自分の領域にレポジトリを作ることが出来る。この読み書きレポジトリをgit cloneでローカルコピーをとったとする。これの基になるレポジトリをリモートレポジトリに登録して、このレポジトリの変更を自分のローカルコピーに反映する。

githubでforkしたレポジトリにfork元を追加して使う

fork元のレポジトリ(読み専用)を追加する。

$ git remote add gray git://github.com/gray/webservice-google-reader.git
$ git remote show
gray
origin
$ git remote show gray
* remote gray
  Fetch URL: git://github.com/gray/webservice-google-reader.git
  Push  URL: git://github.com/gray/webservice-google-reader.git
  HEAD branch: master
  Remote branch:
    master new (next fetch will store in remotes/gray)
  Local ref configured for 'git push':
    master pushes to master (local out of date)

追加したレポジトリの変更をローカルコピーに反映する。

$ git pull
gray     origin
$ git pull gray
remote: Counting objects: 29, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 21 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (21/21), done.
From git://github.com/gray/webservice-google-reader
 * [new branch]      master     -> gray/master
 * [new tag]         0.16       -> 0.16
You asked to pull from the remote 'gray', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
$ git pull gray
0.08     0.09     0.10     0.12     0.13     0.14     0.15     0.16     HEAD     master
$ git pull gray master
From git://github.com/gray/webservice-google-reader
 * branch            master     -> FETCH_HEAD
Auto-merging lib/WebService/Google/Reader.pm
CONFLICT (content): Merge conflict in lib/WebService/Google/Reader.pm
Automatic merge failed; fix conflicts and then commit the result.

コンフリクトがあるのでコンフリクトの解消。

$ vi lib/WebService/Google/Reader.pm

最後に自分のレポジトリにpushして終了。

$ git push
Enter passphrase for key '/home/**************************************':
Counting objects: 1, done.
Writing objects: 100% (1/1), 275 bytes, done.
Total 1 (delta 0), reused 0 (delta 0)
To git@github.com:**********/webservice-google-reader.git
   e7c065a..b4de0fb  master -> master

日常業務はpullしてコード書いてpushする。これはいつもどおり。

リファレンス

  1. Pro Git - Pro Git 2.10 Git の基本 リモートでの作業
  2. git レポジトリ 複数 remote add - Google 検索

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2009-10-30T17:46:36+09:00
  2. Modified: 2009-10-30T17:46:36+09:00
  3. Generated: 2023-08-27T23:09:12+09:00