可以让git跟踪外部回购单个文件? [英] Possible to have git track a single file from an external repo?

查看:75
本文介绍了可以让git跟踪外部回购单个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道子模块,但有一个奇怪的边缘情况,我想避免为外部存储库的代码保留一个单独的目录。

我的毕业论文有一个LaTeX项目:
https://github.com/jklukas/gradthesis



其中使用了一个我保存在单独存储库中的样式文件(供其他人轻松使用):
https://github.com/jklukas/uwthesis



我可以将uwthesis作为子模块,但LaTeX仅在主目录中查找样式文件。在LaTeX中存在一些奇怪的方法,比如在导入样式文件时给出显式路径,但看起来很难看。



目前,我只是保留副本 uwthesis.sty 位于渐​​变回购中。是否有可能将 uwthesis 配置为远程文件,并且能够仅仅为这个文件推送更改?

解决方案

您可以使用正常的 git子模块机制添加您的子模块:

  git submodule add git://github.com/jklukas/uwthesis.git uwthesis 

然后创建一个从顶层目录到相应样式文件的符号链接:

  ln -s uwthesis / uwthesis.sty uwthesis.sty 


I know about submodule, but have a weird edge case where I want to avoid keeping a separate directory for the external repository's code.

I have a LaTeX project for my graduate thesis: https://github.com/jklukas/gradthesis

Which uses a style file which I keep in a separate repository (for others to easily use): https://github.com/jklukas/uwthesis

I could include uwthesis as a submodule, but LaTeX only looks for style files in the main directory. There are hacky ways around this in LaTeX, like giving the explicit path when importing the style file, but that just seems ugly.

Currently, I'm just keeping a copy of uwthesis.sty in the gradthesis repo. Would it be possible to configure uwthesis as a remote and be able to push changes there for just this one file?

解决方案

You could add your submodule using the normal git submodule mechanics:

git submodule add git://github.com/jklukas/uwthesis.git uwthesis

And then create a symlink from the top-level directory to the appropriate style file:

ln -s uwthesis/uwthesis.sty uwthesis.sty

这篇关于可以让git跟踪外部回购单个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆