git drag and press specific files without the repository being saved locally


I have a couple questions but I'll put them together given they look quite similar.

Let's say I have a repository called Repo, and it contains two folders, A and B.

Via terminal (and given I don't have the project in my machine), how can I...

(1) ...clone only folder A from Repo to my machine?

(2) ...send a file/folder C to Repo?

If that repo is on GitHub (since there is a github tag), you can:

  • get just one file with the raw api (see "Download single files from GitHub")<username>/<repo>/<branch>/some_directory/file.rb

That works well for files, and you can repeat that for each file in order to download a folder.
But if said folder content is large, you are best to use the zip link associated to each repo: that won't download the all history, only the current repo state, which is smaller. From that archive, you can extract your folder. See "Download a single folder or directory from a GitHub repo" (maybe you can avoid that with an SVN syntax)

For uploading anything to GitHub, you need to be the owner of the destination repo: you might have to fork the target repo in order to get your own: See GitHub fork repo.

From there you can directly edit a file. This would be cumbersome for a all folder though.