AndrewS
AndrewS

Reputation: 1385

How can I symlink to files in a specific Git ref/branch?

I want to publish a specific subdirectory of a repo via Dropbox, so that directory is publicly downloadable without giving access to the entire repo on Github.

First thing I tried was to symlink from Dropbox to the git project folder (e.g. ln -s /path/to/project/dir ProjectName from within my Dropbox public folder). Then I realized this would change the files every time I switched branches in the repo locally to do work.

Is there some way I could symlink to the version of the directory on the master branch, so it will only change the files in Dropbox when master changes?

Upvotes: 1

Views: 230

Answers (1)

VonC
VonC

Reputation: 1323363

Instead of trying to copy many files to Dropbox, you could considering publishing an archive (a compressed version of the subdirectory you want, at the version that you want)

That would be an "on-demand" process: you would rebuild the archive any time you want to update the content of the archive.

See "git-archive a subdirectory":

git archive -o /path/to/Dropbox/subarchive.zip HEAD:subdir

The archive has no git history in it, but for "publication" that could be enough, and I have seen issues with a git repo in Dropbox before.

You could automate the process with a post-commit hook which would check the current branch (master or not) and make the archive.

Upvotes: 1

Related Questions