Up: Magit   [Index]


13.5.1 Status Buffer

Status

To display information about the current Git repository, type ‘M-x magit-status RET’. You will be using this command a lot, and should therefore give it a global key binding. This is what we recommend:

(global-set-key (kbd "C-x g") 'magit-status)

Status Buffer

Most Magit commands are commonly invoked from the status buffer. It can be considered the primary interface for interacting with Git using Magit. Many other Magit buffers may exist at a given time, but they are often created from this buffer.

Safe State

Return to a safe state:

git reset --hard PRE-MAGIT-STATE

Refresh Status Buffer

Go to the status buffer, while at the same time refreshing it, by typing ‘C-x g’. (When the status buffer, or any Magit buffer for that matter, is the current buffer, then you can also use just ‘g’ to refresh it).

Move Between Sections

Move between sections using ‘p’ and ‘n’. Note that the bodies of some sections are hidden. Type ‘TAB’ to expand or collapse the section at point. You can also use ‘C-tab’ to cycle the visibility of the current section and its children.

Stage Changes

Move to a file section inside the section named “Unstaged changes” and type ‘s’ to stage the changes you have made to that file. That file now appears under “Staged changes”.

Stage and Unstage Hunks

Magit can stage and unstage individual hunks, not just complete files. Move to the file you have just staged, expand it using ‘TAB’, move to one of the hunks using ‘n’, and unstage just that by typing ‘u’. Note how the staging (‘s’) and unstaging (‘u’) commands operate on the change at point. Many other commands behave the same way.


Up: Magit   [Index]