Search code examples
gitgit-submodules

Possible to have git track a single file from an external repo?


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?


Solution

  • 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