Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I list all the different versions of a file, and diff them also?

Tags:

git

using git, I want to list all the different revisions of a given file.

Then, I want to choose a particular version and compare it when another.

How can I do this?

like image 963
mrblah Avatar asked Dec 26 '09 19:12

mrblah


People also ask

How do I get the diff of a file in git?

The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.

How can I find the difference between two commits in a file?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..

What does git diff do?

Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.


1 Answers

To show a history of changes to a particular file, you can use git log:

git log -p -- path/to/file 

The -p tells it to show the diff between each revision and its parent. To get a cumulative diff between two revisions, take the ID of the two revisions, and pass them to git diff:

git diff abc123 def456 -- path/to/file. 

Where abc123 and def456 are the revision IDs.

like image 66
daf Avatar answered Oct 02 '22 15:10

daf