目次

NestDAQ Git Forking Workflow

Fowking Workflow

開発環境を整える: フォークして、手元のPCにクローンして、上流と同期

  1. NestDAQ の Web ページにアクセスする。
  2. Sign in ボタンを押し、自分のアカウントでサインインする。
  3. サインインすると、以下のような状態になる。
  4. 右上あたりの ボタンを押す。
  5. Fork をつくる画面に移行する。基本デフォルトのままでOKのはず。右下の緑の Create Fork ボタンを押す。
  6. nobukoba/nestdaq というリポジトリが作られる。
  7. その後、コマンドライン上での操作になる。
  8. 端末で、Fork した自分のリポジトリをクローンする。
    $ git clone https://github.com/nobukoba/nestdaq.git
    Cloning into 'nestdaq'...
    remote: Enumerating objects: 296, done.
    remote: Counting objects: 100% (54/54), done.
    remote: Compressing objects: 100% (27/27), done.
    remote: Total 296 (delta 38), reused 27 (delta 27), pack-reused 242
    Receiving objects: 100% (296/296), 152.78 KiB | 996.00 KiB/s, done.
    Resolving deltas: 100% (180/180), done.
  9. nestdaq ディレクトリに移動し、git remote -v コマンドで origin を確認。
    $ cd nestdaq/
    $ git remote -v
    origin	https://github.com/nobukoba/nestdaq.git (fetch)
    origin	https://github.com/nobukoba/nestdaq.git (push)
    $ git branch   
    * main
    $ git branch -a
    * main
      remotes/origin/HEAD -> origin/main
      remotes/origin/main
    $ git branch -r
      origin/HEAD -> origin/main
      origin/main
  10. さらに、上流の登録をする。さらに、登録したアドレスを git remote -v コマンドで一応確認しておく。
    $ git remote add upstream https://github.com/spadi-alliance/nestdaq.git
    $ git remove -v
    origin	https://github.com/nobukoba/nestdaq.git (fetch)
    origin	https://github.com/nobukoba/nestdaq.git (push)
    upstream	https://github.com/spadi-alliance/nestdaq.git (fetch)
    upstream	https://github.com/spadi-alliance/nestdaq.git (push)
  11. さらに、https://wiki.idempiere.org/ja/Fork_and_Branch_Git_%E3%83%AF%E3%83%BC%E3%82%AF%E3%83%95%E3%83%AD%E3%83%BC を参考に $ git branch –set-upstream-to=origin/main main と打つ。
    $ git branch --set-upstream-to=origin/main main
    Branch 'main' set up to track remote branch 'main' from 'origin'.
  12. idempiere のページにしたがい、upstreamとの同期する。“クローンしたソースコードがマスターリポジトリと同期していることを常に確認する必要があります。”とのこと。
    $ git checkout main
    Already on 'main'
    Your branch is up to date with 'origin/main'.
    $ git pull upstream main
    From https://github.com/spadi-alliance/nestdaq
     * branch            main       -> FETCH_HEAD
     * [new branch]      main       -> upstream/main
    Already up to date.
    $ git pull origin main
    From https://github.com/nobukoba/nestdaq
     * branch            main       -> FETCH_HEAD
    Already up to date.
  13. 準備完了。

ファイルを編集して、commit して自分のリポジトリに push

  1. 環境が整ったので、自分のリポジトリでいつもやっているように、commit & push する。
  2. 例えば nestdaq/CMakeLists.txt のタイポを直してみる。エディタで nestdaq/CMakeLists.txt ファイルの12-14行目を以下のように編集する。 (14行目の add_compiler_options がtypo、正しくは add_compile_options。)
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
      message("turn on colored error message of Clang")
      add_compiler_options(-fcolor-diagnostics)
               | | |
               V V V
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
      message("turn on colored error message of Clang")
      add_compile_options(-fcolor-diagnostics)
  3. その後、cmake のテストをする。うまくいけば、通常通り commit & push。
    $ git add CMakeLists.txt 
    $ git commit -m "A typo (add_compiler_options --> add_compile_options) was corrected."
    [main 09010b8] A typo (add_compiler_options --> add_compile_options) was corrected.
     1 file changed, 1 insertion(+), 1 deletion(-)
    $ git push
    Enumerating objects: 5, done.
    Counting objects: 100% (5/5), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (3/3), done.
    Writing objects: 100% (3/3), 335 bytes | 335.00 KiB/s, done.
    Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
    remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
    To https://github.com/nobukoba/nestdaq.git
       4dae50f..09010b8  main -> main
  4. これで push 完了。次はプルリク。

上流にプルリクを出す

  1. 修正を上流にマージしてほしい場合は、pull requests を出す
  2. ブラウザーで自分のリポジトリにアクセスする
  3. 左上あたりの Pull requests ボタン を押す。
  4. 以下のような画面に飛ぶ。ここで、緑の New pull request ボタンを出す。
  5. ここで、緑の Create pull request ボタンを出す。
  6. Add a description でコメントを編集し、緑の Create pull request ボタンを出す。
  7. 以下のような画面に飛ぶ。プルリクが承認されると、また見え方が変わるはず。

Troubleshooting