Do you know how to view changes made to a file in GitHub?
If you find a mistake in a file hosted on GitHub, don’t just fix it blindly - check who made the change and why. This helps you understand the context and gives you the chance to inform the contributor if a correction is needed.
GitHub makes it easy to view a file's version history, compare changes, and even see discussions around each commit.
Viewing changes to a file in GitHub
-
Navigate to the file in the repository on GitHub
-
Click on the "History" button (clock icon) at the top right of the file view. You’ll see a list of commits that modified this file
-
Click on a commit to view the diff - the changes between two file versions, showing what was added, deleted, or changed
Figure: Select a commit from the list Figure: View the changes made
If you're working locally, you can also run the following commands to view the exact changes within the terminal.
git log -- path/to/file
git show <commit-hash>