View the change history of a file using Git versioning talks about other ways of viewing history of a file in Git.
Can it be done in Emacs Magit?
View the change history of a file using Git versioning talks about other ways of viewing history of a file in Git.
Can it be done in Emacs Magit?
Since magit 2.1: magit-log-buffer-file
(as per comment below)
Before magit 2.1: magit-file-log
is what you are looking for. It will show you all commits for the file in the current buffer in the standard magit log view.
magit-file-log
was renamed to magit-log-buffer-file
–
Uttasta magit-log-buffer-file
doesn't restrict the display of each commit to just that file. –
Melosa magit-log-buffer-file
and then run magit-ediff-dwim
(bound to "e" shortcut in Spacemacs) on the commit of your choice. This will show a window with two panes with highlighted changes. –
Brickwork l
, -u
, and l
will help after magit-log-buffer-file
–
Downstroke Open your magit-status
buffer, by typing M-x magit-status
(I used to have this bound to C-. C-g
because it is used all the time. These days, I use Spacemacs so it's <SPC> g s
)
l
to get log viewing option--
to set the "Limit to files" option (used to be =f
)l
to view the log of the current branchIf you're using Spacemacs, you can get the history of the currently visited file using <SPC> g f h
--
(Magit 20200112.2023, Git 2.20.1, Emacs 26.1, gnu/linux
) –
Singlehearted magit-log-buffer-file
is what you want. With Spacemacs you can use <SPC> g f h
–
Acerbate (transient-append-suffix 'magit-log "l" '("f" "Current file" magit-log-buffer-file))
, access with C-x M-g l f
. –
Kieffer In your *magit: <project>*
buffer use l
to go into logging mode, then press f
to be prompted for a filename.
If magit (user manual) doesn't have that feature, then you can have a look at other Emacs mode, and add you own git-log-file
function:
(defun git-log-file ()
"Display a log of changes to the marked file(s)."
(interactive)
(let* ((files (git-marked-files))
(buffer (apply #'git-run-command-buffer "*git-log*" "git-rev-list" \
"--pretty" "HEAD" "--" (git-get-filenames files)))) (with-current-buffer buffer
; (git-log-mode) FIXME: implement log mode
(goto-char (point-min))
(setq buffer-read-only t))
(display-buffer buffer)))
C-x v l
–
Shack Symbol’s function definition is void: git-marked-files
–
Dibble I do not know a way. I simply use M-x vc-print-log
which seems to accomplish the same feat. It is not a magit-integrated way, though.
Hit C-c
M-g
to bring up the magit-file-dispatch
: it has several "file-local" magit commands, such as blame and log (l
).
© 2022 - 2024 — McMap. All rights reserved.