Magit and Forge
Diff a PR
From the status page:
' f f
to fetch all topicsn
down to the PR listingd d
(diff dwim) on the PR listing
This doesn't work if you're actually visiting the PR topic (i.e. you hit Enter
on the PR listing and are now in a buffer with a name like *forge: repo
#123*
).
This runs a diff between origin/dev...refs/pullreqs/<PR number>
.
Rebase and move branch pointers
Do the rebase. The same commits will have different SHAs. Old branches will still be at previous SHAs.
- Go to logs buffer
- For each branch:
- check out branch
- move cursor to commit where branch should be moved to
x
to reset to this commit
View File History
M-x magit-log-buffer-file
Previous Version of File
The function magit-find-file
is to "View FILE from REV". Running M-x
magit-find-file
will first prompt for a revision (completes with a list of
all refs), then prompts for a file.
From a specific file:
M-x magit-log-buffer-file
- Move to the commit you want
M-x magit-find-file
View PR Diff
Requires forge.
- Check out the PR (
b
y
) - From main magit buffer, navigate to the PR and visit it with
<enter>
. - With cursor at beginning of buffer,
d
to open the diff menu, thend
to "do what I mean". If this pops up a menu of branches, select the branch you want to diff against (i.e. the branch the PR will be merged into, probablymain
).
Visit File from Diff
Just press <return>
on a chunk in the diff. Buuut, if you want it to use
another window:
(use-package magit :bind (:map magit-diff-mode-map ("M-<return>" . magit-diff-visit-file-other-window)))
View Current and Previous File Version from Diff
- In diff,
<return>
to visit the file M-x magit-find-file-other-window
, branch,<RET>
Cherry pick
A A
. I always forget about this.