Reputation: 471
I'm wondering what's the best way to publicly share a file that's in a private repo on Github.
I would like that every time I make a push to my private repository, the file is automatically updated too.
In particular I have a TeX project. I would like to keep the .tex files secret, but I would like to make the PDF file available to everyone.
Note: I'm aware of the existence of the .gitignore option, but I don't want to use it since I want to keep track of the improvements on the .tex files.
Upvotes: 33
Views: 17342
Reputation: 1328522
I would like to keep secret the tex files but I would like to make available to everyone the pdf file.
You can dedicate a public repo (with a simple README
in it) in order to upload and associate to said public repo an artifact (your pdf) as a GitHub release.
Add that public repo as a submodule of your private repo: that will create a subfolder with the README in it, explaining where to find the pdf (in the release section of the public repo)
You can then, from your own private repo:
All those steps can be scripted, using the GitHub API: here is an example (focused on the release upload part) in bash shell.
Upvotes: 5
Reputation: 417
Github does not provide such functionality. Github repositories are either public or private, but not both. However, if the part you want to share is small enough (let's say 4-5 files), you can create a public gist. Unfortunately, there is no way to update the gist automatically.
Upvotes: 5
Reputation: 49
You can create a public Github repository automatically based on your existing private repository.
You can use git-exporter. It allows you to define file paths available in a public repository. This utility creates a new git repository based on an existing one with a similar commit history. Only allowed files will be included in the commit contents.
Example:
Create config.json
:
{
"forceReCreateRepo": true,
"targetRepoPath": "my-open-source-repo",
"sourceRepoPath": ".",
"allowedPaths": ["*.pdf"],
"ignoredPaths": ["*.tex"]
}
Then run command npx gitexporter config.json
.
New repository my-open-source-repo
includes only "*.pdf"
files.
Then you can push my-open-source-repo
and use it as Open Source.
Like so:
cd my-open-source-repo
git remote set-url origin github.com/orgname/repo-name.git
git push origin master
Upvotes: 2
Reputation: 55
Using the raw link provides a URL with a "token=", which seems to expire after a certain number of days.
Upvotes: 3
Reputation: 712
If it's just one file, you can just use the raw link. Go to that file on GitHub and click "raw"
Just use the link in the adress bar and it should work...
Upvotes: 0