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?
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.
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.
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”
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.
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.
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
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With