Emacs: git, magit-mode
This page is a tutorial of emacs
magit-mode. Magit mode is a excellent interface to the git version control system.
I assume you have used the following git commands in terminal:
If not, i recommend you learn git basics first. 〔➤see Git Basics〕
Install Magit Mode
Install it thru MELPA. Just add MELPA and call
〔➤see Emacs: How to Install Packages Using ELPA, MELPA〕
Using Magit to add, commit, push
First, open a git controlled file, or open its directory in dired.
magit-status to see the project's status.
WARNING: magit around changed its keybinding again. The following is good for magit version in most of to last verified good . To find out the commands/keys in your magit version, in magit mode, press 【Ctrl+h m】 to see the keybinding.
Move cursor to a line, press Tab ↹ to toggle “diff”. (
magit-section-toggle (was “magit-toggle-section”))
Press 【s】 to add the file under cursor to stage. (
magit-stage (was “magit-stage-item”))
Press 【S】 to add all tracked files to stage. (
magit-stage-modified (was “magit-stage-all”))
Press 【u】 to unstage the file under cursor. (
magit-unstage (was “magit-unstage-item”))
Press 【U】 to unstage all staged files. (
magit-reset-index (was “magit-unstage-all”))
Press 【c c】 to write a commit message, then 【Ctrl+c Ctrl+c】 to commit. (
magit-commit-popup (was “magit-key-mode-popup-committing”))
Press 【P】 to push. (
magit-push-popup (was “magit-key-mode-popup-pushing”))
Press 【F】 to pull. (
magit-pull-popup (was “magit-key-mode-popup-pulling”))
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:
describe-function【Ctrl+h f】, then type
- Click on the file name to open the source code file, then call
dired-jump【Ctrl+x Ctrl+j】 to go into that dir. You'll see a file named
universal-argument【Ctrl+u】, then call
info【Ctrl+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
info 【Ctrl+h i】 to view it next time.
〔➤see Emacs: View Info Page〕
or, buy something from my keyboard store.