1

I currently have a repository with 3 separate directories in it. There's two remote servers and my local machine that currently have a copy of the entire repository in each. Is there a way I can set the upstream and origin for these remote machines to a specific folder in the parent repository?

something like

git remote add origin https://github.com/user/repo/pathToSubdirectory.git

or do I need to make a separate repository for each folder?

For example, if I'm on server A I'd like to run git pull and have it pull from the remote repository/folderA.

Thank you!

avenmia
  • 2,015
  • 4
  • 25
  • 49

1 Answers1

2

You might be trying to make a sparse checkout. This means you can checkout only the directory structure of a repository and then select which objects to fetch. Here is a straightforward six-step tutorial how you could sparse-checkout only one (or two, if you like) of your three directories.

Or you might want to use a submodule for each of the three directories. Then they're three separate repositories but you can checkout your whole directory structure using git clone --recurse-submodules

It is not possible to set upstream to a subdirectory the way you described it.

Gamification
  • 787
  • 5
  • 20