Can you share a file and it's history between two git repositories?

后端 未结 2 1065
挽巷
挽巷 2021-01-20 23:23

I\'m not sure if this is possible but I\'d like to be able to have a single file and use it in two projects saved in git repostories. Such that, if I make a change in one projec

相关标签:
2条回答
  • 2021-01-21 00:09

    git submodule command can give you part of the functionality but it requires additional steps to keep the file in sync.

    0 讨论(0)
  • 2021-01-21 00:17

    Along with git submodules, subtree merging is another approach to doing this. You can read a nice write-up in the Pro Git book (free online); there's also an official howto.

    Avery Pennarun has written a specialized Git tool called git-subtree to handle git subtree merging more gracefully. You can read about it in his blog and you can find the code on github. From his post:

    Note that, unlike git submodule, git subtree doesn't change the way people using your project need to work. As far as they're concerned, it's just one big project; nobody has to run (or install) git subtree unless they want to. It can just be the responsibility of a single person to extract the subproject history and upload it to the subproject repository, if you want.

    0 讨论(0)
提交回复
热议问题