简体   繁体   中英

can git subtree include a subtree?

I am writing and R package that needs some java classes. We found those java classes in a python project (licenses are compatible, original author supportive). We don't want to include the whole python project, only one subdirectory that luckily has all we need. Can git subtree do such a thing in a way that makes it push/pull from original (python) repo possible? I know one solution would be to factor out the java part in a separate project and have both python and R project subtree that one. Unfortunately we don't have that kind of control on the original project. Thanks

No, unfortunately that is not possible with git – merging in part of a repository is not supported. But here's a possible workaround:

Create a separate project lib , using git subtree --split on the python repo and add that repo to your R repo, using git subtree --add . Now every time you want to get the updates from python , run git subtree --push on the python repo and git subtree --pull on your R repo.

Note that you could also use submodules to add the lib repo to your python repo, if you prefer that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM