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)
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.
Return to a safe state:
git reset --hard PRE-MAGIT-STATE
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 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.
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”.
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.