R.A. Epigonos et al.

[git] ローカルブランチにマスターブランチの内容をマージ

git で自分のブランチに開発ブランチの内容をマージさせる

公開用ブランチのURLを追加

$ git remote add github git@github.com:l/anope.git

リモートリポジトリのURLを確認

$ git remote -v
github  git@github.com:l/anope.git (fetch)
github  git@github.com:l/anope.git (push)
origin  git://github.com/anope/anope.git (fetch)
origin  git://github.com/anope/anope.git (push)

現在のブランチを確認

$ git branch
  1.8
  1.9
* translation_ja_1.8
  translation_ja_1.8_work
  translation_ja_1.9

開発元ブランチ (origin 1.8)からpullする

$ git pull origin 1.8
From git://github.com/anope/anope
 * branch            1.8        -> FETCH_HEAD
Updating f7bac08..f7b1b19
Fast-forward
 .gitignore                               |    1 +
 Changes                                  |   15 ++-
 Changes.conf                             |   10 +-
 Changes.lang                             |   13 ++-
 Changes.mysql                            |    8 +-
 data/example.conf                        |    2 +-
 docs/COPYING                             |  536 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------
 docs/README                              |   12 +--
 lang/Makefile.win32                      |    7 +-
 lang/cat.l                               |    4 +-
 lang/de.l                                |    4 +-
 lang/en_us.l                             |    4 +-
 lang/es.l                                |    4 +-
 lang/fr.l                                |    4 +-
 lang/gr.l                                |    4 +-
 lang/hun.l                               |    4 +-
 lang/it.l                                |    4 +-
 lang/ja_utf8.l                           |    4 +-
 lang/nl.l                                |    4 +-
 lang/pl.l                                |    4 +-
 lang/pt.l                                |    4 +-
 lang/ru.l                                |    4 +-
 lang/tr.l                                |    4 +-
 src/channels.c                           |   15 +++
 src/config.c                             |   94 ++++++++++------
 src/core/cs_set.c                        |    1 +
 src/core/ms_set.c                        |   21 ++++
 src/core/os_logonnews.c                  |   23 +---
 src/core/os_opernews.c                   |   24 +----
 src/events.c                             |    8 ++
 src/mail.c                               |    2 +-
 src/memoserv.c                           |    1 +
 src/modules.c                            |  637 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------
 src/modules/cs_appendtopic.c             |    2 +
 src/modules/hs_request.c                 |    9 +-
 src/nickserv.c                           |    6 ++
 src/process.c                            |    1 +
 src/protocol/hybrid.c                    |   48 ++++++---
 src/protocol/hybrid.h                    |   10 +-
 src/protocol/inspircd12.c                |   50 ++++++---
 src/protocol/inspircd20.c                |   34 +++++-
 src/protocol/unreal32.c                  |    9 +-
 src/slist.c                              |    4 +-
 src/tools/Anope Install Script.nsi       |  412 +++++++++++++++++++++++++++++++++++-----------------------------------
 src/tools/Anope MySQL Install Script.nsi |  412 +++++++++++++++++++++++++++++++++++-----------------------------------
 version.log                              |   17 ++-
 46 files changed, 1357 insertions(+), 1143 deletions(-)

git pull したら、自動的に origin/1.8 から pull して、git push したら自動的に github/translation_ja_1.8 に push するローカルブランチ translation_ja_1.8 を作りたい。

未設定状態でgit pullするとリモートidとブランチidを指定せよといわれる。さらに、--set-upstream を使ってデフォルト指定する方法も言われる。--set-upstream を使って指定したデフォルト設定は.git/configに書き込まれる。上流側は記憶させておかないと、以前pullしたブランチと違うブランチをpullしてしまって問題が出ることがあるので、まずは記憶させておきたい。

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream translation_ja_1.8 <remote>/<branch>

$  git branch --set-upstream translation_ja_1.8 origin/1.8
Branch translation_ja_1.8 set up to track remote branch 1.8 from origin.
$ cat .git/config
(snip)
[branch "translation_ja_1.8"]
        remote = origin
        merge = refs/heads/1.8

この状態でgit pull すると成功。git pushは失敗。これはoriginにpushしに行くから。僕はoriginにpushすることはできないので、originの管理者に見てもらえるようなリポジトリ github の translation_ja_1.8 ブランチにpushしたい。

$ git pull
Updating f7b1b19..a1607f4
Fast-forward
 .travis.yml                              |    3 +
 Changes                                  |    5 +-
 Changes.conf                             |    9 ++-
 Changes.lang                             |    7 +-
(snip)
 src/users.c                              |    2 +-
 src/win32.rc.template                    |    2 +-
 version.log                              |   10 ++-
 version.log.old                          |    2 +-
 265 files changed, 724 insertions(+), 689 deletions(-)
 create mode 100644 .travis.yml
$ git push
fatal: remote error:
  You can't push to git://github.com/anope/anope.git
  Use https://github.com/anope/anope.git

今のところスマートな解決策が見つからないので、下のようにしている。

$ git push github translation_ja_1.8

ソーシャルブックマーク

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

ChangeLog

  1. Posted: 2010-08-07T11:33:54+09:00
  2. Modified: 2010-08-07T11:33:54+09:00
  3. Generated: 2023-08-27T23:09:13+09:00