3

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?

  • cloning subdirectory is not possible in git itself. You might try using github API, with for example `curl` utility. – max630 Jul 08 '17 at 04:21

2 Answers2

1

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

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
-1

To clone

If you are using git bash git clone [url]

Example: https://github.com/mycode

To commit and push

  1. git init

  2. git add [filename]

  3. git commit -m "First commit"

  4. git remote add origin remote repository URL

  5. git push origin master

(This creates a local clone which you can delete later)

Reference

  1. How to add an existing project
  2. How to clone repository
Community
  • 1
  • 1
user2736738
  • 30,591
  • 5
  • 42
  • 56
  • if I understood, with this you are able to send a file to the project without having to download the whole repository? –  Jul 08 '17 at 02:50
  • @DcCoO Suppose you are working on a file. Then you want to add it to repo, Then you follow what I did in second case. – user2736738 Jul 08 '17 at 02:51
  • @DcCoO You said A or B is not in your machine. So you clone it. And in the second case the file is assumed to be in machine. – user2736738 Jul 08 '17 at 02:53
  • Not really.. in both cases, I don't have the repository locally. In the first case I want to get a specific file (e.g. A) from Repo without downloading Repo completely. In the second case I want to send a file to Repo without downloading it as well. –  Jul 08 '17 at 02:55
  • @DcCoO.: I am afraid that there is no proper way to do that. – user2736738 Jul 08 '17 at 03:14
  • @VonC.: So my answer is also right...look it is not possible to do it epo to repo? right? – user2736738 Jul 08 '17 at 05:28