Source TreeのGit Flow操作にオプションをつける
Source TreeのGit Flow操作にオプションをつける
Source TreeでReleaseブランチを完了するときにエラーが発生した。
gitコマンドにオプションをつければ良いことは分かったが、SourceTreeでの実現方法が分からなかった。
結論としては、 下記フォルダ内のgit flowのコマンドに対応するファイルを修正する。
C:\Users{ログインユーザー}\AppData\Local\Atlassian\SourceTree\gitflow_local\gitflow\
環境
- Source Tree Ver1.9.13.7
- Windows 7
現象
git flowのブランチワークに沿って管理しているプロジェクトでReleaseブランチを完了するときにエラーが発生した。
エラー内容
Switched to branch 'master' Your branch is up-to-date with 'origin/master'. fatal: refusing to merge unrelated histories There were merge conflicts.
原因
git 2.9以降のバージョンのデフォルト設定では、共通のノードを持たないブランチはマージできないようになっているらしい。
"git merge" used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The command has been taught not to allow this by default, with an escape hatch
--allow-unrelated-histories
option to be used in a rare event that merges histories of two projects that started their lives independently. https://stackoverflow.com/questions/37937984/git-refusing-to-merge-unrelated-histories-on-rebase
対応
上記引用にもあるが、コマンドの場合は"--allow-unrelated-histories"オプションをつければよい。
Source Treeで実現するには、Release完了時に実行される下記ファイルを修正する。
C:\Users\{ログインユーザー}\AppData\Local\Atlassian\SourceTree\gitflow_local\gitflow\git-flow-release
# master(228行目)とdevelop(258行目)へのマージがあるので2ヶ所修正する。 # git merge --no-ff "$BRANCH" || \ # ↓の様に変更する。 git merge --no-ff "$BRANCH" --allow-unrelated-histories || \