LoginSignup
0
0

More than 5 years have passed since last update.

Fedora 25 で Git のマージツールに P4Merge を使う

Last updated at Posted at 2017-04-18

Fedora 25 の Git でマージツールに P4Merge を使う場合はひと工夫必要です、という話。

P4Merge をインストール

Perforce の公式サイトから P4Merge をダウンロードします。
https://www.perforce.com/downloads/helix

わかりづらいですが、P4Merge は HELIX P4V: VISUAL CLIENT に含まれています。
Visual Client をダウンロードしましょう。

Screenshot from 2017-04-18 19-41-24.png

ダウンロードしたら、tarball なので適当なところに展開します。

$ cd /opt
$ sudo tar xf ~/Downloads/p4v.tgz

PATH の設定

展開先の bin/ ディレクトリを ~/.bash_profile を編集するなどして PATH に追加しておきます。

~/.bash_profile
PATH=$PATH:/opt/p4v-2017.1.1491634/bin
export PATH

.gitconfig の設定

git mergetool 時に P4Merge を使うように ~/.gitconfig を設定します。

~/.gitconfig
[merge]
  tool = p4merge
[mergetool]
  keepBackup = false
[mergetool "p4merge"]
  path = /opt/p4v-2017.1.1491634/bin/p4merge
  keepTemporaries = false
  trustExitCode = false

p4merge の起動スクリプトを配置

ここがひと工夫の部分。
Fedora 25 の Git はなぜか P4Merge サポートが入ってません。
(P4Merge がプロプライエタリ・ソフトウェアだからだろうか)
デフォルトだと以下のようなエラーメッセージが出てしまいます。

$ git mergetool
git config option merge.tool set to unknown tool: p4merge
Resetting to default...

Git のソースリポジトリから P4Merge 用のスクリプトを自分でとってくる必要があります。

$ cd /usr/libexec/git-core/mergetools
$ sudo wget https://github.com/git/git/raw/v2.9.3/mergetools/p4merge

確認

適当なリポジトリで git mergetool して P4Merge が立ち上がったらOK。

以上です。

0
0
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
0