Is there a way to push a commit to a remote git repo, without first making a local clone of that repo?
I have a valid URL for the remote repo, I know the path of the
Well, if you use GitHub, then you could do this easily with GitHub API
https://developer.github.com/v3/repos/contents/#create-or-update-a-file
Basically you do:
Create OAuth App and get Access Token
https://developer.github.com/apps/building-oauth-apps/
Make request to GitHub API:
Set Authorization header with your Access Token (OAuth 2.0)
PUT https://api.github.com/repos/:owner/:repo/contents/:path
with JSON body like this:
{
"message": "my test commit through API",
"content": "QmFzZTY0IGVuY29kZWQgY29udGVudCBoZXJl",
"sha": "cd220ncv229f2e4a95bce426ff48b1ae6b885b3a42"
}
Where:
message - your commit message
content - updated content encoded in Base64 format
sha - sha for updating file, you can get it by API request
GET https://api.github.com/repos/:owner/:repo/contents/:path
:owner - repository owner
:repo - repository name
:path - path to file within repository
Example request:
https://api.github.com/repos/nodejs/node/contents/README.md