How to know who created a file in a folder by API?

By this API GET /projects/:id/repository/files/:file_path ( Repository files API | GitLab), we can get the last_commit_id of a single file in the repository. In this way, we can know who is the last modifier.

However, there is no corresponding information of something like first_commit_id which can be used to know who created a file.

In stead, we can list all commits of a file by GET /projects/:id/repository/commits?path={file_path} ( Commits API | GitLab) to find the first commit, however, this is quite inefficient, the API does not support sort by reverse date.

Wondering does any one know if there are any efficient way to know who creates a file?

To find who created a file in GitLab, the API can tell you the last modifier, but it doesn’t directly show the creator. You can list all commits for a file, but it’s inefficient because there’s no reverse sorting.

Here’s what you can do:

  1. Use git log locally to find the first commit that added the file.
  2. Use the API to list commits and manually find the first one, but it’s not very efficient.

GitLab doesn’t currently offer an easy way to directly get the file creator through the API.

,

Learn More: www.concretesrichmondva.com