How Can I Show What a Commit Did?
This write-up will demonstrate the methods to show what a particular commit did.
How to Show What a Commit Did?
Different Git commands can be used to show what a particular commit did, such as:
Method 1: View Commit Changes Using “git show <commit-id>” Command
The “git show” command along with the commit ID shows detailed information about that commit including the commit message, author name, date, and time. It also shows what a particular commit did.
Step 1: Select Desired Commit
First, display the commit history, and choose a particular commit.
The below output shows all the commit history. We have selected the “3245529” commit id:
Step 2: View Commit Changes
Then, utilize the “git show” command along with the selected commit ID to view its changes:
The below output shows the changes made to the selected commit. In the highlighted part, the green text along with the “+” symbol represents the new lines added to the file in the commit:
Moreover, the “–stat” option can also be used in the same command to view the brief list of changes:
The below screenshot indicates that three insertions have been added to this commit:
Method 2: View Commit Changes Using “git diff <commit-id>^!” Command
The “git diff” command with the specific commit ID is used to view the changes made to that commit. Use the provided command and add the “^!” symbols to exclude all of the parent commits from the diff:
In the below screenshot, the highlighted part shows the changes added in the selected commit:
We have explained the easiest methods to show what a specific commit did.
Conclusion
To show what a particular commit did, first, select the desired commit and copy its commit ID. Then, execute the “git show <commit-id>” or “git diff <commit-id>^!” command to view the changes added to that commit. This write-up demonstrated the methods to show what a particular commit did in Git.
Source: linuxhint.com