Emacs: magit-mode Tutorial

, , …,

This page is a short intro to emacs's magit-mode. Magit mode is a excellent interface to the git version control system.

You should already have used {git-status, git-add, git-commit, git-push, git-pull} in terminal. If not, see git real basics.

Install Magit Mode

Install it thru MELPA. Just add MELPA and call list-packages. 〔☛ A Guide on Emacs 24 Package System

Using Magit to add, commit, push

Call dired and go into a dir of your git repository, or open one of your git controlled file.

Call magit-status to see your status.

emacs magit-mode status screenshot 2013-06-08
emacs magit-mode status screenshot

Move cursor to a line, press Tab ↹ to toggle diff.

Press 【s】 to add the file under cursor to stage.

Press 【S】 to add all tracked files to stage.

Press 【u】 to unstage the file under cursor.

Press 【U】 to unstage all staged files.

Press c to write a commit message, then 【Ctrl+c Ctrl+c】 to commit.

git-push

Press 【P P】 to push.

git-pull

Press 【F F】 to pull.

git-log

emacs magit-mode 2013-06-09
Emacs magit-log screen.

Call magit-log to see your commit log. Press Enter ↵ on a line to see its diff.

View Magit Documentation

Magit comes with complete documentation. It's located at the same dir magit-mode.el is at.

To view the doc:

  1. Call describe-functionCtrl+h f】, then type magit-mode.
  2. Click on the file name to open the source code file, then call dired-jumpCtrl+x Ctrl+j】 to go into that dir. You'll see a file named magit.info
  3. Call universal-argumentCtrl+u】, then call infoCtrl+h i】, then type the file name.

Once you've done this, the Magit doc is added to the info index. So, you can just call infoCtrl+h i】 to view it next time.

See also: Emacs: Info-mode Keys.

blog comments powered by Disqus