Showing which files have changed between two revisions

In this article you will see that what is git diff and how see difference between two files and how to see difference between two revisions and two commits

 

To show which files have changed between two revisions in Git, you can use the git diff command. The git diff command compares two commits and shows the differences between them.

 

Here's the basic syntax for using git diff to compare two revisions:

git diff <revision1> <revision2>

Replace <revision1> and <revision2> with the two revisions you want to compare. You can specify revisions using their commit hashes, branch names, or tags.

 

For example, to show the changes between the latest commit and the previous commit, you can run the following command:

git diff HEAD~ HEAD

 

To show the changes between two branches, you can run the following command:

git diff <branch1> <branch2>

Replace <branch1> and <branch2> with the names of the two branches you want to compare.

 

git diff --stat --color master..branchName

This will give you more info about each change, while still using the same number of lines.

 

You can also flip the branches to get an even clearer picture of the difference if you were to merge the other way:

$ git diff --stat --color branchName..master

 

The output of the git diff command will show you the changes between the two revisions, including the additions, deletions, and modifications of lines in the affected files.

You can also use the git log command to view the changes between revisions in a more compact format. The git log command displays a list of the commits, with information about each commit, including the author, date, and message. You can use the --stat option to view a summary of the changes made in each commit.

 

 


Tags:

git

Share:

Related posts