Luke Taylor
Luke Taylor

Reputation: 9571

Git without complete local copy

Say I have a largish repo on GitHub, and I'm pushing from a computer with a very small amount of space. I'd like to push files one by one without having to keep every file from the remote. If I wanted to edit a file from the remote, I'd download it, make my changes, and then push back up to the remote. Is there any way to do this?

I want to do this programmatically for a web service.

Upvotes: 1

Views: 70

Answers (1)

Dan Lowe
Dan Lowe

Reputation: 56627

You may be able to implement this using GitHub's API.

You can retrieve the content of a file given the path:

https://developer.github.com/v3/repos/contents/#get-contents

This method returns the contents of a file or directory in a repository.

GET /repos/:owner/:repo/contents/:path

Files and symlinks support a custom media type for retrieving the raw content or rendered HTML (when supported). All content types support a custom media type to ensure the content is returned in a consistent object format.

And you can also update the content at a given path:

https://developer.github.com/v3/repos/contents/#update-a-file

This method updates a file in a repository

PUT /repos/:owner/:repo/contents/:path

You can also create new files, or delete files.

https://developer.github.com/v3/repos/contents/#create-a-file

https://developer.github.com/v3/repos/contents/#delete-a-file

The API is extensive - you can find much more in the documentation.

Upvotes: 1

Related Questions