Emacs Package: Magit
Introduction
Section titled “Introduction”User-friendly interface for Git source control tool for many operations like:
- Creating and amending commits
- Managing and merging branches
- Pulling from and pushing to remotes
- Reading commit logs and “blaming” source files
- Cherry—picking
- Rebasing
- Using the reflog
Installation
Section titled “Installation”Not required when using Spacemacs
(use-package magit :ensureSee Emacs Shortcuts for Magit - Emacs Shortcuts for Magit for common tasks.
-
Navigation:
- Move forward/backward in sections:
nandp - Move forward/backward in logical section (e.g. file, change)
M-nandM-p - Move to parent section
^
- Move forward/backward in sections:
-
Open transient Magit panel:
?- good way to learn all commands
Multiple Repositories View and Operations
Section titled “Multiple Repositories View and Operations”Sources: How to use magit-list-repositories, git operations from magit-list-repositories
- Use
magit-list-repositoriesto view all repositories in a directory and perform operations on them. - With the above buffer, use
magit-repolist-modeto perform operations on marked repositories like fetch withmagit-repolist-fetch.
Magit diff, Checking Differences between branches
Section titled “Magit diff, Checking Differences between branches”Source: local PR review, git worktrees, find breaking changes (go) - bashbunni YouTube
Use magit-diff and press e to see side by side changes of diff in
context of the range selected.
Example process to check differences in branches:
- Go into a feature branch
magit-diff-range, choose main branch- See diff
- Choose diff and enter the file
magit-merge-previewto see changes likemagit-diff-range