3

I'd like to add a subfolder of a public github repository into a subfolder of my own repository. I found a few solutions with git-sub-tree but there seems to be no way to pull changes from the original repository.

Is there a solution where I can merge changes from upstream?

LandoR
  • 908
  • 1
  • 5
  • 22
  • Why not [`git subtree pull`](https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt)? – phd Jun 13 '19 at 23:46

2 Answers2

1

Did you try submodules? I think they will work for your use case.

abelgana
  • 312
  • 2
  • 6
  • nope you can only add a entire repo. (https://stackoverflow.com/questions/5303496/how-to-change-a-git-submodule-to-point-to-a-subfolder) – LandoR Jun 14 '19 at 09:34
1

If you need just one folder, you could clone the repo in another directory and then symlink the needed subdir.

$ pwd
> my-repo
$ cd ..
$ git clone <other-repo>
$ cd my-repo
$ ln -s ../other-repo/path/to/subdir ./directory/for/subdir/from/other/repo
fortea
  • 345
  • 4
  • 15
  • 1
    Then my repository would only have a link to an unknown file. I want to track my changes against upstream. – LandoR Jun 14 '19 at 09:36