Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View a file's history in Magit?

Tags:

git

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?

like image 448
eugene Avatar asked Jan 16 '13 07:01

eugene


People also ask

How do you check the history of a file in Git?

Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.

How do I use Magit Emacs?

To use Magit, type M-x magit-status or C-x M-g j . You can also type C-x p m to open a Magit status buffer in your project root, if you use that functionality in Emacs. The status window is the most common entryway into Magit, but it is not the only one.


2 Answers

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.

like image 194
Ragge Avatar answered Oct 14 '22 11:10

Ragge


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)

  1. Type l to get log viewing option
  2. Type -- to set the "Limit to files" option (used to be =f)
  3. Enter the file path you wish to view history for
  4. Type l to view the log of the current branch

If you're using Spacemacs, you can get the history of the currently visited file using <SPC> g f h

like image 40
Bryan Ash Avatar answered Oct 14 '22 12:10

Bryan Ash