View the change history of a file using github.com

GitGithub

Git Problem Overview


I've found this post about using the command line, but is it possible to view the file change history of a single file in a repository on github.com?

An in-browser solution would help me to better illustrate changes to team members while in meetings.

Git Solutions


Solution 1 - Git

You can view the change history of a file by clicking on the history button, or by adding commits to the URL of the file. Here is what it looks like for a file at the Homebrew repository on GitHub:

https://github.com/mxcl/homebrew/commits/master/SUPPORTERS.md

To get a line-by-line history, simply add the SHA-1 string of the commit for which you want to see the diff to the URL after the word commit, and then anchor it with the filename you are interested in. For the same file above:

https://github.com/mxcl/homebrew/commit/288f001e924d5365b79c279e4478f372a04011ae#SUPPORTERS.md

Solution 2 - Git

As @BurhanKhalid say, but here explaining as a "GitHub fast guide", with URL syntax:

  1. Browse your project at https://github.com/<USER>/<PROJECT> ...
  2. ... then you have a URL ending with the file path: https://github.com/<USER>/<PROJECT>/blob/master/<PATH>
  3. Now you have all, is only to change "blob/master" to "commits/master": https://github.com/<USER>/<PROJECT>/commits/master/<PATH>

PS: to remember "commits/master" click at the project's home in the "Commit" link.

Ops: there are a similar answer here, @TimHenigan expressed with http://github.com/<username>/<project>/commits/<branch>/<path/to/file>


Question to GitHub developers team

Why do you not offer a direct link for this kind of browsing? We need it, like Wikipedia readers need "history" link!


Ops, GitHub's team is listening to us?

Now (June 2014) when you browse through the folders, an icon appears, see "browse commits" above right. When you click, the tree/master URL turns commits/master.

Still missing to have the same for files, as showed here, but was an evolution.

Solution 3 - Git

I think git-history is an alternative and good method for quickly browsing the history of files in any Git repository.

You don't need to download anything. You only need to replace some text in the URL.

Steps to do:

  1. Go to a file in GitHub (or GitLab, or Bitbucket)
  2. Replace github.com with github.githistory.xyz

There is Chrome and Firefox extensions to add an Open in Git History button on GitHub, GitLab and Bitbucket so that you don't need to memorize step 2.

For more information, you can go to its GitHub page.

Solution 4 - Git

The GitHub capabilities for history exploration for a file just got a bit better in Apr. 2021 with:

> ## "View file at a specific point in the commit history"

> When viewing the commit history of a single file, users can now click to view that file at the selected point in history. > > https://i1.wp.com/user-images.githubusercontent.com/16675781/116747128-c01edc00-a9fd-11eb-9009-008305786885.gif?ssl=1 -- view history

From there, type "b" for the blame view of that file in that commit, and explore its changes:

> With the blame view, you can view the line-by-line revision history for an entire file, or view the revision history of a single line within a file by clicking before.
> > Each time you click before, you'll see the previous revision information for that line, including who committed the change and when. > > Git blame view

Solution 5 - Git

Check out https://github.com/pomber/git-history a very handy UI tool (and plugin) visualization of file changes through time.

enter image description here

Solution 6 - Git

As of , if you want to view all the change records in a easy way on GitHub, NO, I did not find an easy way to do that in browser.

How you view one commit change history on GitHub:

  1. You visit any file, let's say hello.cpp on GitHub, click the "history" button, then you can see the commits that change this file.
  2. Then by clicking each commit's "sha" button, you see the whole commit.
  3. Then you find hello.cpp, click "view file" button. And finally you only see the difference of this commit - last commit.

So if you want to look through all the history changes, you have to repeat the process above for so many times.. and open so many tabs...


You can use gitk [filename](GUI) or git log -p filename(Command line) to view all history changes of a single file easily.

Source: https://stackoverflow.com/questions/278192/view-the-change-history-of-a-file-using-git-versioning

Solution 7 - Git

Both Github Desktop and github.com have surprisingly limited capabilities for history diffs.

Option 1 (preferred): migrate to Atlassian Bitbucket; much better experience overall; integration with JIRA, etc.

Option 2: if you are on Windows - try Tortoise GIT desktop client; has Show Log feature which I find very helpful for side-by-side diffs.

Solution 8 - Git

You can read this official article firstly, and then I will show you a demo!

https://developer.github.com/v3/repos/commits/

> Here is the demo, using the fetch API:

PS: client_id & client_secret you should using yourself!

let username = `xgqfrms-GitHub`;
     repo = `Node-CLI-Tools`;

fetch(`https://api.github.com/repos/${username}/${repo}/commits`,{
    data: {
        client_id: '08ecc2f68d922f188xxx',
        client_secret: '5846d428b5340812b76c9637eceaee979340bxxx'
    }
})
.then((response) => response.json())
.then((json)=> {
    console.log(`json = ${json}`);
    return repos = json;
})
.then((repos)=>{
    console.log(`repos = ${repos}`);
    console.log(`repos = ${repos.length}`);
    for (let i = 0; i < repos.length; i++) {
        console.log(`repos${i}  = ${repos[i].commit.message}`);
    }
});

Solution 9 - Git

Checkout out Little Differ in the Google Chrome webstore. It's a Chrome extension that shows a sidebar displaying the commit history of a repository or a file.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpropstmView Question on Stackoverflow
Solution 1 - GitBurhan KhalidView Answer on Stackoverflow
Solution 2 - GitPeter KraussView Answer on Stackoverflow
Solution 3 - GitYnjxsjmhView Answer on Stackoverflow
Solution 4 - GitVonCView Answer on Stackoverflow
Solution 5 - GitAziz AltoView Answer on Stackoverflow
Solution 6 - GitRickView Answer on Stackoverflow
Solution 7 - GitPaul ShiryaevView Answer on Stackoverflow
Solution 8 - GitxgqfrmsView Answer on Stackoverflow
Solution 9 - GitgtriaView Answer on Stackoverflow