Как сделать репозиторий приватным
Перейти к содержимому

Как сделать репозиторий приватным

  • автор:

Как я могу переключить публичное репо на частное и наоборот на GitHub?

Я не могу найти способ сделать это. Это вообще возможно? Поскольку в моем случае это важно, есть ли платформа управления кодом, где это возможно?

2 ответа

Вместо того, чтобы переключаться между состояниями видимости репозитория GitHub (что возможно через репозиторий) Настройки, раздел «Опасная зона»), я бы лучше установил 2 репозитория:

  • один публичный, только с публичным контентом
  • один частный, со смесью публичного и частного контента

Таким образом, вам не нужно удивляться, нажимая на хранилище, является ли он сегодня общедоступным или закрытым: вы бы нажимали на одно конкретное хранилище (из двух), хорошо зная его статус видимости.
И вы никогда бы не открыли частный контент, который установлен на общедоступный уровень даже через несколько минут, . больше никогда не будет по-настоящему приватным (потому что его можно клонировать, реплицировать и передавать в другое место)

Чтобы переключить репозиторий на GitHub с публичного на приватное или наоборот, следуйте этим инструкциям:

How to make your public repository as private and vice versa in GitHub?

W hile creating a repository in GitHub, according to requirement, the repository is made either public or private but later on the requirements of an individual can change as well due to which the repository settings might have to be changed. Hence, in this blog, I will be discussing how you can make your public repository as a private repository and vice versa. But first of all, let’s have an overview of what does public and private repository refers to in GitHub.

How can I switch a public repo to private and vice versa on GitHub?

I can’t seem to find a way to do this. Is it possible at all? Since this is kind of important in my case, is there a code management platform where this is possible?

3 Answers 3

Instead of switching back and forth between GitHub repository visibility status (which is possible through the repository settings, section "danger zone"), I would rather establish 2 repositories:

  • one public, with only public content
  • one private, with a mix of public and private content

That way, you don’t have to wonder, when pushing to a repository, if it is today public or private: you would push to one specific repository (of the two), knowing full well its visibility status.
And you would never expose private content, which, is set to public even a few minutes, . is no longer ever truly private (because it can be cloned, replicated and pushed elsewhere)

You can now set your repository to any available visibility option – public, private, or internal – from a single dialog in the repository’s settings.

Previously, you had to navigate separate sections, buttons, and dialog boxes for changing between public and private, and between private and internal.

https://docs.github.com/assets/images/help/repository/repo-change-select.png

(*) "destructuve action" because of the consequences of the visibility change:

public to private: some features won’t be available in the repository after you change the visibility to private. Any published GitHub Pages site will be automatically unpublished.
GitHub Advanced Security features, such as code scanning, will stop working

private to public: GitHub will detach private forks and turn them into a standalone private repository

Note that, since July 10th 2020, the default visibility is private:

Default visibility for new repositories

When you create a repository, you can choose whether it should be private or public.

Now, when you’re signed into GitHub through an organization’s single sign on service and create a new repository through the website navigation, the default selection is Private.

This helps prevent sensitive company data from unintentionally being pushed to public repositories. See the about repository visibility article for more information about this choice.

Setting repository visibility

We recommend reviewing the following caveats before you change the visibility of a repository.

Making a repository private

  • GitHub will detach public forks of the public repository and put them into a new network. Public forks are not made private.
  • If you’re using GitHub Free for personal accounts or organizations, some features won’t be available in the repository after you change the visibility to private. Any published GitHub Pages site will be automatically unpublished. If you added a custom domain to the GitHub Pages site, you should remove or update your DNS records before making the repository private, to avoid the risk of a domain takeover. For more information, see «GitHub’s products and «Managing a custom domain for your GitHub Pages site.»
  • GitHub will no longer include the repository in the GitHub Archive Program. For more information, see «About archiving content and data on GitHub.»
  • GitHub Advanced Security features, such as code scanning, will stop working. For more information, see «About GitHub Advanced Security.»

Making a repository public

  • GitHub will detach private forks and turn them into a standalone private repository. For more information, see «What happens to forks when a repository is deleted or changes visibility?»
  • If you’re converting your private repository to a public repository as part of a move toward creating an open source project, see the Open Source Guides for helpful tips and guidelines. You can also take a free course on managing an open source project with GitHub Skills. Once your repository is public, you can also view your repository’s community profile to see whether your project meets best practices for supporting contributors. For more information, see «About community profiles for public repositories.»
  • The repository will automatically gain access to GitHub Advanced Security features.

For information about improving repository security, see «Securing your repository.»

Changing a repository’s visibility

On GitHub.com, navigate to the main page of the repository.

Under your repository name, click

Settings. If you cannot see the «Settings» tab, select the

dropdown menu, then click Settings.

Screenshot of a repository header showing the tabs. The "Settings" tab is highlighted by a dark orange outline.

Under «Danger Zone», to the right of to «Change repository visibility», click Change visibility.

Change visibility button

Select a visibility.

Dialog of options for repository visibility

To verify that you’re changing the correct repository’s visibility, type the name of the repository you want to change the visibility of.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *