両方とも前のリビジョン
前のリビジョン
|
|
emacs:emacs26.1_use_magit_on_windows_10 [2019-10-27 14:26] Decomo |
emacs:emacs26.1_use_magit_on_windows_10 [2021-08-14 23:50] Decomo |
v2.90からtransientパッケージも必要になったっぽい? | v2.90からtransientパッケージも必要になったっぽい? |
| |
| ==== git実行ファイルの設定 ==== |
| |
==== Magitの設定 ==== | Magitはgitコマンド実行時に''magit-git-executable''変数のgitコマンドを使用する。 |
| |
最も重要なのが''magit-git-executable''変数の中身。変数名の通り、Magitはgitコマンド実行時に本変数の値を利用する。 | [[https://magit.vc/manual/magit/Git-Executable.html|マニュアル]]によれば、WindowsとmacOSではMagit読み込み時にgitコマンドの絶対パスが設定される。[[https://github.com/magit/magit/blob/456735401b6524f822fecc3fbb49a5c9199f9d4d/lisp/magit-git.el#L135|magit-git.el]]を見ると、何やらgitコマンドのパスを求める処理が確かに入っている。環境変数PATHが通っているgit.exeを自動で探してくれるようだが、上手く設定されない場合は手動で設定する。 |
| |
''magit-git.el''の''(defcustom magit-git-executable)''を見るとわかるのだが、Windows用に特殊な処理が入っており、変数値が''C:\Program Files\Git\bin\git.exe''といった絶対パス指定となることがある。 | TRAMPを使ってリモートのリポジトリを操作する場合は、''magit-remote-git-executable''が使用される。大抵、リモート環境といえばUNIX系だと思うが、その場合はデフォルト値の"git"のままで動くはず。動かなければリモート環境のgitをフルパスで設定してやる。 |
| |
TRAMPを使ってリモートのリポジトリを操作する場合は、<fc #ff0000>リモート側のgit実行ファイルを指定</fc>する必要がある。 | |
| |
今回はリモートのLinuxマシンが対象だったので、init.elで以下のように指定した。 | |
| |
<code lisp> | <code lisp> |
(require 'magit) | (require 'magit) |
(setq magit-git-executable "git") | (setq magit-git-executable "U:/msys64/usr/bin/git.exe") |
| ;(setq magit-remote-git-executable "/path/to/remote/git") |
</code> | </code> |
| |
とりあえず何も指定せずgit管理下のファイルを開き、M-x magit-statusをしてみて、正しいレポジトリパスを指定したにも関わらず「Create repository in /path/to/gitrepo/?」と聞かれたら、Magitがgitコマンドが見つけられなかった可能性が高い。それからmagit-git-executableをアレコレ指定してみるのが良いだろう。 | まずは何も指定せずgit管理下のファイルを開き、M-x magit-statusが動くかどうかを見るのが手っ取り早い。Git管理下にもかかわらず「Create repository in /path/to/gitrepo/?」や「Searching for program: No such file or directory, git」出たら、Magitがgitコマンドを見つけられなかった可能性が高い。それからmagit-git-executableをアレコレ指定してみるのが良いだろう。 |
| |
この辺はTRAMPの設定やら、TRAMPの実行パス環境やらも絡んでて非常にわかりづらい。 | この辺はPATHやらTRAMPの設定やら接続先の環境やらが絡んでて非常にわかりづらい。 |
| |
===== 参考サイト ===== | ===== 参考サイト ===== |
| |
* [[https://emacs.stackexchange.com/questions/27461/magit-doesnt-recognise-git-repo-through-ssh-connection|tramp - Magit doesn't recognise git repo through ssh connection - Emacs Stack Exchange]] | * [[https://emacs.stackexchange.com/questions/27461/magit-doesnt-recognise-git-repo-through-ssh-connection|tramp - Magit doesn't recognise git repo through ssh connection - Emacs Stack Exchange]] |
* [[https://qiita.com/khiraiwa/items/bf9924f3a19c780c6ae9|EmacsのTRAMPとmagitでリモートのリポジトリを扱えなかった件について]] | * [[https://qiita.com/khiraiwa/items/bf9924f3a19c780c6ae9|EmacsのTRAMPとmagitでリモートのリポジトリを扱えなかった件について]] |
* [[https://stackoverflow.com/questions/26630640/tramp-ignores-tramp-remote-path|emacs - TRAMP ignores tramp-remote-path - Stack Overflow]] | * [[https://stackoverflow.com/questions/26630640/tramp-ignores-tramp-remote-path|emacs - TRAMP ignores tramp-remote-path - Stack Overflow]] |
* [[https://emacs.stackexchange.com/questions/35055/magit-with-tramp-is-not-working-with-git-correctly|magit with tramp is not working with git correctly - Emacs Stack Exchange]] | * [[https://emacs.stackexchange.com/questions/35055/magit-with-tramp-is-not-working-with-git-correctly|magit with tramp is not working with git correctly - Emacs Stack Exchange]] |
* [[https://qiita.com/takc923/items/c7a11ff30caedc4c5ba7|EmacsのGitクライアント:Magit]] | * [[https://qiita.com/takc923/items/c7a11ff30caedc4c5ba7|EmacsのGitクライアント:Magit]] |
* [[http://yamakichi.hatenablog.com/entry/2016/06/29/133246|Emacs Magit使い方 - yamarkz's blog]] | * [[http://yamakichi.hatenablog.com/entry/2016/06/29/133246|Emacs Magit使い方 - yamarkz's blog]] |