简体   繁体   中英

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?

使用GIT无法做到这一点。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM