0

I have a private GitHub repository as follows

X
├── .git
└── (project files)

I am trying to add a private GitHub repository (project Y) into project X.

X
├── .git
├── (project files)
└── Y
    ├── .git
    └── (project files)
    

How can I add project Y to my current project X?

afp_2008
  • 1,940
  • 1
  • 19
  • 46
  • 1
    [Git Submodules?](https://git-scm.com/book/en/v2/Git-Tools-Submodules) *It often happens that while working on one project, you need to use another project from within it.* – 0stone0 Mar 30 '21 at 20:58
  • 1
    Does this answer your question? [How do I work with a git repository within another repository?](https://stackoverflow.com/questions/1811730/how-do-i-work-with-a-git-repository-within-another-repository) – 0stone0 Mar 30 '21 at 20:59

1 Answers1

2

You can't have "two projects in one". But you can have two separate projects where the project at the top level folder will ignore a sub-folder. That folder will be the top level folder for the other project.

In project X, create a gitignore file with an entry to ignore folder Y.

Y/

Project X, ignoring project Y.

X
├── .git
├── (project files)
├── .gitignore
└── Y
    ├── .git
    └── (project files)
Adrian J. Moreno
  • 14,350
  • 1
  • 37
  • 44