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

  1. Navigate to the file in the repository on GitHub

    github file
    Figure: File within GitHub UI

  2. 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

    github history button
    Figure: GitHub history button

  3. Click on a commit to view the diff - the changes between two file versions, showing what was added, deleted, or changed

    github commit viewer
    Figure: Select a commit from the list
    github diff view
    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>

We open source.Loving SSW Rules? Star us on GitHub. Star
Stand by... we're migrating this site to TinaCMS