Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 820
Jeff Klukas Avatar asked May 08 '12 17:05

Jeff Klukas


2 Answers

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
like image 68
larsks Avatar answered Oct 18 '22 21:10

larsks


If your problem is only

push changes there for just this one file

you can add all files, excluding one, to .gitignore like this:

*
!path/to/explicit.file

and clear your local repo index:

git rm -r --cached .

Then add, commit and push whatever you want.

like image 5
radistao Avatar answered Oct 18 '22 22:10

radistao