简体   繁体   中英

Share file by two github repos?

Let's say I have two projects on github:

  • Project 1: a.cpp and ch
  • Project 2: b.cpp and ch

Now, I could set up two repos, both having ch However, this is bad: If I change ch for Project 1, I need to copy ch on my hard disk into Project 2 and then push both.

Other solution: Make 3 projects: one for each file. However, people who download Project 1 (with the a.cpp) have to manually download Project 3 (with the ch) into Project 1's directory.

Is there any way to make sharing of ch easy on github?

http://git-scm.com/book/en/Git-Tools-Submodules

Git supports something called submodules that sound like what you would need. In your example, you would have ch be in its own repository and both projects would include that repository as a submodule. I'm assuming of course that there will be far more things in that submodule than just that one file.

Pitfall: Projects that include submodules usually point to a particular commit in that submodule until and unless you fetch the submodule again and tell your application to use the newest commit (and thus the newest versions of the files).

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