LoginSignup
0
1

More than 5 years have passed since last update.

本家とは異なるリポジトリで作業しているプロジェクトで本家のtagをマージする手順メモ

Last updated at Posted at 2018-06-17

概要

例えばOSSのリポジトリを独自開発するときなんかに、度々本家の最新版をマージしたい時があるのでその手順をメモ。
もっと良い方法もあるかも?

手順

  1. (初回のみ)本家リポジトリを作業中リポジトリのリモートリポジトリに登録する

    # 本家とわかるような名前をmainrepoとしておく
    $ git remote add mainrepo https://repo.addr/
    
  2. 本家をfetchする

    $ git fetch mainrepo
    
  3. マージしたいtagなりcommitなりのブランチを切る

    # タグ一覧を出力して最新をチェック
    $ git tag
        1.0
        1.1
        2.0
        2.1
        2.2
    
    # 2.2をマージしたいと仮定してブランチを切る
    $ git checkout -b mainrepo_2.2 refs/tags/2.2
    
  4. branchをチェックしマージ用ブランチを切る

    # 現在のブランチを確認
    $ git branch
          master
          xxxxxx
          yyyyyy
        * mainrepo_2.2
    
    #masterへマージしたいのでまずmasterへ切り返る
    $ git checkout master
    
    #masterへ直接マージするのはよろしくないのでマージ用ブランチを切る
    # ブランチ名をv22_merge_to_masterとでもする
    $ git checkout -b v22_merge_to_master
    
  5. マージ

    # 自動でv22_merge_to_masterへ切り替えられるが念のため確認
    $ git branch
          master
          xxxxxx
          yyyyyy
          mainrepo_2.2
        * v22_merge_to_master
    
    # マージ
    $ git merge mainrepo_2.2
    

6 事後処理

# コンフリクト処理などを行う
$ git mergetool

# デフォルトでvimdiffで開くことが多い
# noobなので個人的には:diffoffしてハイライト消した後に/HEADなんかで
# HEADを検索してジャンプして消してるんだけどいい方法があればおしえてくだしあ

動作確認が完了したら
masterにマージするなりプルリク発行するなり
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1