1

I have repository A which has "normal behavior".

In that repo I have a readme.md, About.md, some folders with other files etc. What I want know is to add separate folder for my homeassistant automation which I'm running on Raspberry Pi (this will be repository B).

I successfully added on local, and connected with my github through console from my Pi, but it wont let me do a "push" command as expected because, I didn't do "pull", but those files I really don't need on my Pi, it will mess up my configuration.

I would like to have structure like

Project (Repository A)
 - Readme.md
 - Folder1
   - SomeFile.txt
 - RepositoryB Folder (in this folder will be pushed form my Pi files and config)

Should I just use a fork on repositoryB which will be a separate repo?
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Stefan89BEG
  • 129
  • 2
  • 4
  • 17

1 Answers1

1

You could include repository B as a submodule in repository A via git submodule add https://github.com/<name-of-repo-B>. With this approach, you can independently push/pull changes to repository A and repository B.

When cloning a repository that has submodules included you must execute git submodule update --init --recursive afterward to clone the submodules.

Be aware that using pull on repository A would not update repository B when having B included as a submodule. To update B as well, you can run git submodule update --remote --recursive in repository A or git pull in repository B (git submodule update --remote vs git pull).

See https://git-scm.com/book/en/v2/Git-Tools-Submodules

It also seems you can only clone a subdirectory of a Git repository as of Git 2.19 (How do I clone a subdirectory only of a Git repository?)

mattefrank
  • 231
  • 1
  • 9
  • The partial clone trick in Ciro Santelli's answer uses things that aren't really *finished* yet: if you start doing this sort of thing, you'll get trapped into a morass of needing to work on Git itself. :-) That's not necessarily a bad thing, but just be aware of what you're getting into when you start using these experimental promisor-packs. – torek Apr 18 '20 at 22:29