Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make public only one file of a private git repository?

From my private git repository, I would like to make a single file publicly available. Is there a way to achieve this in say GitHub, BitBucket or elsewhere?

Let me be more precise. I have a Latex project containing, say:

main.tex
chapters/chapter1.tex
...
chapters/chapterN.tex 
main.pdf

I would like to make main.pdf publicly available and distribute a link pointing to it, while keeping the remaining files private. Is there a way to achieve this?

like image 589
k88074 Avatar asked May 03 '18 07:05

k88074


People also ask

How do I make one GitHub file public?

Changing a repository's visibilityOn GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings. Under "Danger Zone", to the right of to "Change repository visibility", click Change visibility. Select a visibility.

Can you fork a private repository and make it public?

No. You can fork it and it still remains private. Private collaborators may fork any private repository you've added them to without their own paid plan. Their forks do not count against your private repository quota.

How do I hide files in a GitHub repository?

Just mark your repository as private by going to your repository's Settings -> Danger Zone -> Change repository visibility.

Can others see my private repository GitHub?

Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.


2 Answers

It is not possible to do it with GIT.

like image 141
miguelbemartin Avatar answered Oct 13 '22 04:10

miguelbemartin


In your case, it's better to use some tools which can automatically export your file to another public git repo.

You can use git export tool for that.

You need to create gitexporter.config.json like so:

{
    "forceReCreateRepo": true,
    "targetRepoPath": "my-open-source-repo",
    "sourceRepoPath": ".",
    "allowedPaths": ["main.pdf"]
}

and then run npx giteporter gitexporter.config.json.

These tools create a new repo my-open-source-repo with the same commit history as your current . repo. The my-open-source-repo repo will contain only your main.pdf file and its history.

like image 28
pahaz Avatar answered Oct 13 '22 04:10

pahaz