![]() |
To show files changed between two revisions in Git, you can use the git diff command with specific commit references. Here’s a step-by-step guide: Table of Content Using Git DiffThe
git diff --name-only commit1 commit2
git diff commit1 commit2
Using Git LogThe
git log --name-only --oneline commit1..commit2
git log -p commit1..commit2
Using Git DifftoolIf you prefer using a graphical tool to see the differences, you can use
git config --global diff.tool meld
git difftool commit1 commit2
Using Git ShowTo see the files changed in a specific commit, you can use
git show --name-only commit
git show commit
Identify the RevisionsDetermine the commit references (hashes or branch names) representing the two revisions you want to compare. You can use git log to view the commit history and find the appropriate references. git log --oneline
Run the Diff CommandOnce you have identified the commit references, use the git diff command to compare the files changed between the two revisions. git diff <old_revision> <new_revision>
Replace <old_revision> and <new_revision> with the commit references representing the older and newer revisions, respectively. View the DifferencesAfter running the git diff command, Git will display the differences between the files changed in the two revisions. The output will show the changes made to each file, including additions, deletions, and modifications. Optional: View Unified DiffYou can use the -u or –unified option to display the differences in a unified diff format, which provides more context around the changes. git diff -u <old_revision> <new_revision>
This command will show the differences in a format that includes additional context lines. Review and Analyze ChangesAnalyze the differences shown in the output to understand the changes made between the two revisions. You can review the added, deleted, and modified lines to gain insight into the differences. By following these steps, you can easily show files changed between two revisions in Git using the git diff command. This allows you to identify and understand the changes made within a specific range of commits, aiding in code review, debugging, and version comparison. |
Reffered: https://www.geeksforgeeks.org
Git |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |