- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2019-03-18T15:15:52+00:00","","")
#author("2019-06-04T14:34:54+00:00","","")
#topicpath
///////////////////////////////////////////////////////////////////////////////
* 目次 [#o9fa6d61]
#contents();
///////////////////////////////////////////////////////////////////////////////
* magit [#ycbd3850]
- [[emacs>Editor/emacsen]] 上で動作する、[[git>VersionCtl/Git]] フロントエンド
//=============================================================================
** 導入方法 [#installing]
- Linux の場合、ディストリビューションによっては用意されている場合もある
-- debian の場合、 magit パッケージを aptitude install すると、即使えるようになる。
- リポジトリ: https://github.com/magit/magit.git
- 最近のバージョンでは dash.el を必要とする。導入済みでない場合は用意しておく必要がある。
-- dash.el のリポジトリ: https://github.com/magnars/dash.el
-- with-editor のリポジトリ: https://github.com/magit/with-editor.git
- ${HOME}/.emacs.d/site-lisp/ 配下に手動インストールした場合の設定例。magit と dash に load-path も通す必要がある。
; magit
(setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/dash") load-path))
(load-library "~/.emacs.d/site-lisp/dash/dash.el")
(setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/with-editor") load-path))
(load-library "~/.emacs.d/site-lisp/with-editor/with-editor.el")
(setq load-path (cons (expand-file-name "~/.emacs.d/site-lisp/magit") load-path))
(load-library "~/.emacs.d/site-lisp/magit/magit.el")
- emacs23 以下の emacs 環境では、 defvar-local 関数が存在しない関係で、使える magit のバージョンは 1.2.2 以下となる。
- with-editor.el は元々 magit に組み込まれていたが、下記の commit 以降で外に出されており、別途自分で組み込む必要がある
commit e87fe8180b6513450a110b7ad4fed887895720c3
Author: Jonas Bernoulli <jonas@bernoul.li>
Date: Thu Jan 28 21:01:06 2016 +0100
move with-editor to its own repository
///////////////////////////////////////////////////////////////////////////////
* コマンド [#o7c058aa]
- magit のキーバインドは、バージョンによって幾つか変更されているものがあるので注意が必要。~
Version 2.1.0 であれば "h" でhelp を参照出来、2ストロークなキーバインドのものについては都度コマンド候補が表示されるので、それを参照すれば良い。
** version 2.8.0 [#m8e9c8da]
*** 'keymap' Property Bindings: [#bffeb7ed]
|~binding |~command |~remark |
| C-j |magit-diff-visit-file-worktree | |
| C |magit-commit-add-log | |
| K |magit-file-untrack | |
| R |magit-file-rename | |
| a |magit-apply | |
| s |magit-stage | |
| u |magit-unstage | |
| <C-return> |magit-diff-visit-file-worktree | |
| <remap> |Prefix Command | |
| <remap> <magit-delete-thing> |magit-discard | |
| <remap> <magit-revert-no-commit> |magit-reverse | |
| <remap> <magit-visit-thing> |magit-diff-visit-file | |
*** Major Mode Bindings: [#lc7c188a]
|~binding |~command |~remark |
| C-c |Prefix Command | |
| TAB |magit-section-toggle | |
| RET |magit-visit-thing | |
| C-w |magit-copy-section-value | |
| C-x |Prefix Command | |
| ESC |Prefix Command | |
| SPC |magit-diff-show-or-scroll-up | |
| ! |magit-run-popup | |
| $ |magit-process-buffer | |
| + |magit-diff-more-context | |
| - |magit-diff-less-context | |
| 0 |magit-diff-default-context | |
| 1 |magit-section-show-level-1 | |
| 2 |magit-section-show-level-2 | |
| 3 |magit-section-show-level-3 | |
| 4 |magit-section-show-level-4 | |
| 5 .. 9 |digit-argument | |
| : |magit-git-command | |
| < |beginning-of-buffer | |
| > |end-of-buffer | |
| ? |magit-dispatch-popup | |
| A |magit-cherry-pick-popup |git cherry-pic の操作メニューを表示 |
| B |magit-bisect-popup | |
| D |magit-diff-refresh-popup | |
| E |magit-ediff-popup |git diff の操作メニューを表示する |
| F |magit-pull-popup | |
| F |magit-pull-popup |pull の操作メニュー・・・は表示されないが、 &br;''F u'': magit-pull-from-upstream &br;''F p'': magit-pull-from-pushremote &br;''F e'': magit-pull-branch &br;がそれぞれ実行出来る。 |
| G |magit-refresh-all | |
| I |magit-gitignore-locally | |
| L |magit-log-refresh-popup | |
| M |magit-remote-popup |git remote の操作メニューを表示する |
| O |magit-subtree-popup | |
| P |magit-push-popup |git push の操作メニューを表示 |
| S |magit-stage-modified | |
| T |magit-notes-popup | |
| U |magit-unstage-all |stage されている全てのファイルを unstage する |
| V |magit-revert-popup | |
| W |magit-patch-popup | |
| X |magit-reset-popup |git reset の操作メニューを表示する |
| Y |magit-cherry | |
| Z |magit-stash-popup |git stash の操作メニューを表示する |
| ^ |magit-section-up | |
| b |magit-branch-popup | |
| c |magit-commit-popup |git commit の操作メニューを表示する |
| d |magit-diff-popup | |
| e |magit-ediff-compare | |
| f |magit-fetch-popup | |
| g |magit-refresh | |
| h |magit-dispatch-popup | |
| i |magit-gitignore | |
| j |Prefix Command | |
| k |magit-delete-thing | |
| l |magit-log-popup |git log の操作メニューを表示する |
| m |magit-merge-popup | |
| n |magit-section-forward | |
| o |magit-submodule-popup | |
| p |magit-section-backward | |
| q |magit-mode-bury-buffer | |
| r |magit-rebase-popup | |
| s |magit-stage-file |選択中のファイルを stage する |
| t |magit-tag-popup |git tag の操作メニューを表示する |
| u |magit-unstage-file |選択中のファイルを unstage する |
| v |magit-revert-no-commit | |
| w |magit-am-popup | |
| x |magit-reset | |
| y |magit-show-refs-popup | |
| y |magit-show-refs-popup |branch 操作の操作メニューを表示。機能としては v.2.1.0 での magit-branch-popup に近い。 |
| z |magit-stash-popup |git stash の操作メニューを表示 |
| DEL |magit-diff-show-or-scroll-down | |
| S-SPC |scroll-down-command | |
| <C-tab> |magit-section-cycle | |
| <M-tab> |magit-section-cycle-diffs | |
| <backtab> |magit-section-cycle-global | |
| <remap> |Prefix Command | |
| <s-tab> |magit-section-cycle-global | |
| <remap> <dired-jump> |magit-dired-jump | |
| j f |Prefix Command | |
| j n |magit-jump-to-untracked | |
| j p |Prefix Command | |
| j s |magit-jump-to-staged | |
| j t |magit-jump-to-tracked | |
| j u |magit-jump-to-unstaged | |
| j z |magit-jump-to-stashes | |
| C-c C-c |magit-dispatch-popup | |
| C-c C-e |magit-dispatch-popup | |
| C-x 4 |Prefix Command | |
| C-x a |magit-add-change-log-entry | |
| M-RET |magit-dired-jump | |
| M-1 |magit-section-show-level-1-all | |
| M-2 |magit-section-show-level-2-all | |
| M-3 |magit-section-show-level-3-all | |
| M-4 |magit-section-show-level-4-all | |
| M-n |magit-section-forward-sibling | |
| M-p |magit-section-backward-sibling | |
| M-w |magit-copy-buffer-revision | |
| <remap> <evil-next-line> |evil-next-visual-line | |
| <remap> <evil-previous-line> |evil-previous-visual-line | |
| j p p |magit-jump-to-unpushed-to-pushremote | |
| j p u |magit-jump-to-unpushed-to-upstream | |
| j f p |magit-jump-to-unpulled-from-pushremote | |
| j f u |magit-jump-to-unpulled-from-upstream | |
| C-x 4 a |magit-add-change-log-entry-other-window | |
** version 2.1.0 [#r1ba0815]
|~binding |~command |~remark |
|M-x: magit-status | magit-mode 起動 | |
| h |magit のヘルプを表示 | |
| E |magit-diff-popup |git diff の操作メニューを表示する |
| M |magit-remote-popup |git remote の操作メニューを表示 |
| F |magit-pull-popup |git pull の操作メニューを表示 |
| P |magit-push-popup | git push の操作メニューを表示 |
| s | git add | 選択中のファイルを stage に追加(commitの対象に)する |
| S |全ファイルを stage に追加する | |
| u |magit-unstage |ファイルを stage から降ろす |
| U |magit-unstage-all |全ファイルを stage から降ろす |
| c |commit log を書く | |
| C-c C-c | git commit | commit する |
| C-c C-a | git commit --amend | commit をやり直す |
| b |magit-branch-popup | git branch の操作メニューを表示 |
| l | git log | log を表示する。 l-l でshort log, l-L で verbose な log を表示する |
| z | git stash | stash を作成する |
| a | git stash apply | stash を適用(apply)する |
| A |magit-cherry-pick-popup | git cherry-pick の操作メニューを表示する |
| k | git stash drop | stash を drop(最新の stash 1つを list から削除)する |
| %%b%% y | | branch-manager を起動する&br;(2015-11-26 以降、従来の magit-branch-manager に代わり、新たな I/F が "y" で起動するようになった) |
| f f | git fetch (Current) | |
| f o | git fetch (commit) | |
| f a | git fetch (all remotes) | |
| m | git merge | |
| M-x: magit-reflog | git reflog |そのリポジトリ上で行った git の操作履歴を表示する |
| d | git diff |ローカルの編集差分の表示 |
| r |magit-rebase-popup| git rebase の操作メニューを表示する |
| t |magit-tag-popup |git tag の操作メニューを表示する |
| T |magit-notes-popup | |
//=============================================================================
** diff [#d6b0165e]
- リポジトリと差分のあるファイルのファイル名の上で "e" を type すると、emacs の ediff を利用した差分編集画面が起動する。
- この diff の画面は、ある時期に 2ペインから3ペインに変更されているが、これは "e" に割り当てられた関数が変更されたため。
|~画面 |~関数 |
|2ペイン |magit-ediff-compare |
|3ペイン |magit-ediff-dwim |
- 最新の magit で、差分編集を以前の2ペインにしたい場合は、magit を読み込んだあとの方で、以下を記述する
(define-key magit-mode-map "e" 'magit-ediff-compare)
-- これで、若干面倒ではあるが(その代わり比較対象をどのブランチにするかなど、手動で都度選べるようにもなる)、2ペインの diff が使えるようになる。
-- 但し、conflict 解決の場合に magit-diff-compare を起動すると、(マージや rebase による)conflict 前後の比較ではなく、conflict した結果と現在の HEAD との比較となってしまう。この場合には magit-ediff-dwim を起動するようにする。~
→ ''"e"'' と ''"E"'' で両者を使い分けると良いだろう。
///////////////////////////////////////////////////////////////////////////////
* link [#y086fb37]
- [[It's Magit! A Git Porcelain inside Emacs>https://magit.vc/]] --- 開発元
- [[magit.el を試してみた>http://gom.hatenablog.com/entry/20090524/1243170341]]
- [[[git][emacs] magitメモ>http://w.koshigoe.jp/study/?%5Bgit%5D%5Bemacs%5D+magit%A5%E1%A5%E2]]
- [[Magitユーザーマニュアル>https://docs.google.com/document/d/1v1lw539dpN3EVksU-CAjD-4vFeb_w3Ez3Y2RfVlE2F8/edit]]
///////////////////////////////////////////////////////////////////////////////
* 環境構成(メモ) [#r624029e]
** emacs 25.1.1 [#i8d7999f]
|~module |~heads |
|magit |refs/tags/2.8.0 |
|magit-popup |refs/tags/v2.12.5 |
|dash |refs/tags/2.13.0 |
|with-editor |refs/tags/v2.5.0 |
- magit 2.5.0 は、(環境問題もあるかも知れないが)改行コードが CR/LFのファイルの差分編集をうまく扱えない問題がある。