info:magit#Top
info:magit#Repository setup You can create a git repo with M-x magit-init. This will create a git-repo in the current directory.
(magit-init)
help:magit-init
info:magit#Repository setup
M-x magit-clone
This will prompt you for a repo, which is either a url, or a path, and a path to clone it to.
help:magit-clone
info:magit#Status buffer
Run M-x magit-status to see the status of your repo.
Press “g” in the window to refresh it.
press “n” (next) or “p” (previous) to navigate in this window.
help:magit-status
info:magit#Staging and unstaging
In the magit-status window, put your cursor on an unstaged file and press “s”.
If you press TAB on the file, it will expand to show the changes that are unstaged. Deletions show in red, and additions in green. The changes are in “hunks”.
You can unstage a file with “u”
info:magit#Initiating a commit
info:magit#Editing commit messages
In the magit-status window with some files that are staged, press “c”, review the options, and probably press “c” again. Enter a commit message and type “C-c C-c” to commit it, or “C-c C-k” to cancel it.
info:magit#Diffing
From the magit-status window, press “d” then “d” to see what has changed.
info:magit#Logging
In the magit-status window press “l”, review the options, and press “l” again.
If you want to see only the commits that affected a file, in the magit-status window press “l” then “=f”, enter the filename, and then press “l” again.
info:magit#Pushing
In the magit-status window press “P” then “p”.
Note that tags don’t normally get pushed, but there are options (“T” to push a tag, and “t” to push all tags).
info:magit#Pulling In the magit-status window press “F” then “p”.
info:magit#Running Git manually In the magit-status window, type “!” to get the popup and choose what you want to do (e.g. where to run the command, etc… You do not need to type “git” in the command. Note you can also run a shell command from this interface.
Press “$”
info:magit#Keystroke Index
Use M-x magit-checkout-file select the branch, or enter a revision, and then choose a file.
help:magit-checkout-file
help:magit-find-file help:magit-find-file-other-window
In a magit-status window press “l =g” enter a pattern to grep for, and then press “l”.
info:magit#Reverting
Got to the log, select the commit and type “V” then “V”.
info:magit#Tagging
press “t” in the magit-status window. You can then create a tag, annotate it, delete tags, and prune them.
info:magit#The branch popup
In the magit-status window press “b” then “b” and choose the branch.
To checkout a new branch, in the magit-status window press “b” then “c”. Choose the branch to start from then a name for the new branch.
info:magit#Merging
In the magit-status window press “m”, then “m” and select the branch to merge into the current one.
info:magit#Resolving conflicts
You will probably also want to get familiar with info:ediff#Top.
On a file in a magit-status window, press “e” to enter the 3-window ediff view. The A window is the version at HEAD, the B window is what is in the index, and the C window is the current version.
info:magit#Fetching
In the magit-status window press “f”.
info:magit#Remotes
M-x magit-remote-add then enter an alias, and the url.
info:magit#Stashing
Press “z” in the magit-status window
info:magit#Resetting
info:magit#Rebasing
Open the log, select the oldest commit you want to rebase on then press “r” and then “i”. Use M-p and M-n to move commits around. Press “s” on any commits you want to squash into the commit above it. C-c C-c will start the commands.
From the magit-status on unpushed commits, you can also press “r” to get the rebase popup.
“r w” allows you to reword the commit message.
info:magit#Creating and sending patches
In magit-status window, press “W”
“W p” creates patches “W r” makes a pull request. This just creates an email with information in it. It is not a GitHUB request, and it is only useful if there is a public, external copy of the repo.
info:magit#Cherry picking
Press “A”
info:magit#Applying patches
info:magit#Notes
Press “T” to attach a note.
A typical use of notes is to supplement a commit message without changing the commit itself. Notes can be shown by git log along with the original commit message. To distinguish these notes from the message stored in the commit object, the notes are indented like the message, after an unindented line saying “Notes (<refname>):” (or “Notes:” for refs/notes/commits).
info:magit#Cherry picking