Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View the change history of a file using Git versioning

Tags:

git

git-log

How can I view the change history of an individual file in Git, complete details with what has changed?

I have got as far as:

git log -- [filename] 

which shows me the commit history of the file, but how do I get at the content of each of the file changes?

I'm trying to make the transition from Microsoft Visual SourceSafe and that used to be a simple right-click → Show history.

like image 812
Richard Avatar asked Nov 10 '08 15:11

Richard


People also ask

How do I see revision history 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 see file changes in history?

Right-click a file or folder in the project and click Show History. In the Change Explorer view, open a change set, right-click a file or folder in the change set, and select Show History.

Which command is used to view the history of the changes in git?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.


2 Answers

For a graphical view I'd use gitk:

gitk [filename] 

Or to follow filename past renames:

gitk --follow [filename] 
like image 104
Claudio Acciaresi Avatar answered Oct 12 '22 09:10

Claudio Acciaresi


You can use

git log -p -- filename 

to let Git generate the patches for each log entry.

See

git help log 

for more options - it can actually do a lot of nice things :) To get just the diff for a specific commit you can

git show HEAD 

or any other revision by identifier. Or use

gitk 

to browse the changes visually.

like image 26
VolkA Avatar answered Oct 12 '22 08:10

VolkA