Emacs: git, magit-mode
Magit tutorial for beginner.
All you need to know is Alt+x
magit-status and 6 keys:
- Tab → toggle show diff.
- s → stage
- u → unstage
- c c → commit
- P → push
- F → pull
Following are details.
magit-mode is the best interface to the git version control system.
I assume you have used the following git commands in terminal:
[see Git Basics]
Install Magit Mode
Install it thru MELPA. [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.
Move cursor to a line, press Tab to toggle “diff”. (Command name
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 c】 to write a commit message, then 【Ctrl+c Ctrl+c】 to commit. (
Press 【P】 to push. (
Press 【F】 to pull. (
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 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 Alt+x
dired-jump【Ctrl+x Ctrl+j】 to go into that dir. You'll see a file named
universal-argument【Ctrl+u】, then Alt+x
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]
If you have a question, put $5 at patreon and message me.