Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get commits history for one file in github api?

I would like to get all commit messages for separate file in github REST api. But all I got - only to get all commits for separate branch. Then I tried to get following:

http://api.github.com/users/<username>/<project>/commits/<branch>/<path/to/file>

But that didn't help also. Is this at least possible?

like image 836
vmeln Avatar asked Apr 05 '13 10:04

vmeln


People also ask

Can you see commit history in GitHub?

On GitHub, you can see the commit history of a repository by: Navigating directly to the commits page of a repository. Clicking on a file, then clicking History, to get to the commit history for a specific file.

How do I see all commits?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.

How do I get the history of a commit in Git?

Other git history commands There are at least two other git history/log/patch commands you can use to show the history of commits for a file: $ git log -- divLhsSkyAd.scala.html # one-line summary info $ git log -p divLhsSkyAd.scala.html # detail about each “patch”

How do I view the detailed commit history for a file?

Git FAQ: How do I view the detailed commit history for a file? Solution: When you want the detailed git commit history for a file, this is the best git command I know: $ git log -p --follow -- <filename>. The -p option says “show all patch information,” and the --follow option tells git to also show information in the event a file has been renamed.

What are commits in Git?

Commits are the building blocks of "save points" within Git's version control. By using commits, you're able to craft history intentionally and safely.

How to view changes of a single commit in git log?

And, if you just want to view the changes of a single commit from the log, you can copy the hash and run git show: Just having a list of commits can be messy to sort out branches. Luckily git log provides the --graph option which can be used alongside some


2 Answers

Try this (as described in the API docs here):

http://api.github.com/repos/:owner/:repo/commits?path=PATH_TO_FILE

e.g.

https://api.github.com/repos/izuzak/pmrpc/commits?path=README.markdown

like image 189
Ivan Zuzak Avatar answered Oct 17 '22 09:10

Ivan Zuzak


Using GraphQL API v4, for a file on the default branch, it would be :

{
  repository(owner: "izuzak", name: "pmrpc") {
    defaultBranchRef{
      target {
        ...on Commit{
            history(first:100,path: "README.markdown"){
            nodes {
              author {
                email
              }
              message
              oid
            }
          }
        }
      }
    }
  }
}

Try it in the explorer

like image 8
Bertrand Martel Avatar answered Oct 17 '22 08:10

Bertrand Martel