Как удалить форк на github

от admin

Случайно форкнул проект в GitHub, как теперь его удалить?

Случайно форкнул проект в GitHub. Проект x64dbg. Удалил у себя все файлы, но каталог master x64dbg остался.

Как от него избавиться? И желательно от истории тоже.

Форк — это самостоятельный репозиторий на GitHub, он создается для того, чтобы вы могли продолжить работу над проектом, сохранили всю историю изменений до форка и могли делать пулл-реквесты.

Если вам нужно только получить последнюю версию проекта, то форк для этого не нужен. Можно клонировать «родительский» репозиторий, причём достаточно будет неполного (неглубокого) клонирования.

Чтобы полностью удалить любой проект на GitHub (не обязательно форк):

Deleting a repository

You can delete any repository or fork if you’re either an organization owner or have admin permissions for the repository or fork. Deleting a forked repository does not delete the upstream repository.

Only members with owner privileges for an organization or admin privileges for a repository can delete an organization repository. If Allow members to delete or transfer repositories for this organization has been disabled, only organization owners can delete organization repositories. For more information, see «Repository roles for an organization.»

Deleting a public repository will not delete any forks of the repository.

Warnings:

  • Deleting a repository will permanently delete release attachments and team permissions. This action cannot be undone.
  • Deleting a private repository will delete all forks of the repository.

Some deleted repositories can be restored within 90 days of deletion. For more information, see «Restoring a deleted repository.»

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, click Delete this repository.

Repository deletion button

Read the warnings.

To verify that you’re deleting the correct repository, type the name of the repository you want to delete.

Deletion labeling

Click I understand the consequences, delete this repository.

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

How to unfork a GitHub repository (2023 official method)

Who doesn’t love GitHub? And who hasn’t their GitHub account cluttered with forked repositories of projects you’ve long stopped contributing too? Do you want to clean up your account and unfork outdated repositories? Learn how to unfork a GitHub repo the correct way.

How to unfork a repository

Unfortunately, GitHub doesn’t offer an Unfork repository button. Unforking is a manual process which needs to be done by a GitHub employee. But because of the large demand for unforking or detaching repositories, GitHub has built a special chatbot to enter your request. Luckily, the GitHub team performs unfork requests very fast, so it’s very likely that it takes only a few minutes to half an hour.

How to detach/extract a GitHub repository

Go to support.github.com/request (or go to GitHub.com and click Contact GitHub in the footer).

Click Attach, detach or reroute forks.

In the Subject field, typ ‘Unfork’. A blue banner should appear with ‘Our virtual assistant can help’. Click the banner.

A chat should appear on screen with the Virtual Assistant. Paste the URL of the repository.
_Note: make sure to paste the URL to the forked repository, so not the original repository. It should look like github.com/username/forked-repo-name.

Specify what should be done with Child forks:

If username/forked-repo-name has child forks, what should we do with these?
Commonly you’ll want to bring the child forks along with you when detaching your fork from the upstream repository.

  1. Bring the child forks with the repository
  2. Leave the child forks behind

Select one of the options and send the form.

Within a few minutes to half an hour you should get a confirmation in your e-mail.

Now you’ve successfully unforked a GitHub repository! The repository stays in your account as a personal repository, without ties to the original repository.

Using the GitHub visual assistant to unfork a repository.

Using the GitHub virtual assistant to unfork a GitHub repo.

The GitHub assistant to unfork a repository.

What is GitHub forking?

GitHub is a great tool for developing software. Millions of developers and companies build, ship and maintain their software on GitHub. If you’ve used GitHub for a while, you may find yourself wanting to contribute to someone else’s project. Or you would like to use an other project as a starting point for your own project. GitHub makes this really easy by allowing you to fork other people’s projects. But what about unforking?

If your project is finished or if you’ve made your contribution, the forked repository will still be shown in your account as ‘forked from X’.

Published by Ralph J. Smit on 02 February 2021 in Github. Last updated on 22 February 2023.

Cleaning up forked GitHub repositories with

One great thing about using GitHub is the ability to view and contribute to others’ code. Even the code underlying many of our favourite packages is available for us to examine and play around with.

Forking a repository is a great way to create an exact replica of someone else’s project in our own user space. We can then freely make changes to this copy without affecting the original project. If you end up especially proud of your changes, you can then submit a Pull Request to offer them up to the owner of the original repository. However, your fork doesn’t have to end up in a contribution — you can also just keep experimenting with the code forever or use it as a starting point for your own project.

A forking mess

If you are an avid forker of GitHub repos, your original repositories on GitHub may quickly become crammed in between an endless stream of forked repos. Your user space has become very cluttered, with old forks that you haven’t looked at in years still taking up space. Well, now it’s time for some spring cleaning and the first task is de-cluttering your repositories by removing forks.

Do you use Professional Posit Products? If so, checkout out our managed Posit services

Manually cleaning

You can manually delete repositories using the GitHub interface. Go to the repository you wish to delete, then select Settings at the top of the page

The Settings button on your repository

Then scroll to the bottom of the page and enter the Danger Zone marked by a red box.

Deleting a repo from the Danger Zone

From there, you can select Delete this repository which will prompt you to confirm that you are absolutely sure of what you’re doing by typing out the name of the repository. Note that after deleting the repository, the action cannot be undone. Also note that if you are deleting a forked repository, deleting it will only remove it (including any changes you have made to it) from your own GitHub — you won’t accidentally delete the original project (phew).

So it is possible to clean up your GitHub manually and this might be the most suitable way if you’re only wanting to delete 1-2 repositories. But let’s say you’ve forked over fifty repositories. Manually going into each one, finding the delete button in the settings and typing in the confirmation prompt is not what you want to spend your day doing. As with all manual methods, pointing and clicking does not scale particularly well.

Using the package

To use the package, you first need to generate a Personal Access Token (PAT).

Getting a token

Creating a personal access token to be able to use the GitHub API is easy. You can either navigate to the page on GitHub (Settings > Developer Settings > Personal Access tokens > Generate new token), or you can use the handy create_github_token() function from which will open the same page in your browser.

Adding a new Personal access token.

From there, you give your token a useful name as well as select what access should be granted by the token. Note: if you want to use to delete unwanted forked repositories, you will need to select the delete_repo scope.

Setting the delete_repo scope for your token.

However, be aware that this allows you to delete any repo — not just forked ones. After deciding on the scopes, you generate your token. As the page tells you, you will have to store your token somewhere as you won’t be able to access it again after closing the page. We recommend copying it and storing it in a password manager such as LastPass. Once you have saved your token somewhere secure, you can make it available to your R environment using the set_github_pat() function from the package which will prompt you to enter your PAT, which you did save somewhere… right? If you did not follow our advice and now no longer have access to your PAT, don’t worry, you can delete the old one on GitHub and generate a new one.

Viewing existing tokens

OK, now that you’ve definitely got your token ready, you can run the code below

which will prompt you to enter your PAT. Now you can finally get to the cleaning!

Cleaning

We will load the package, as well as the package to get access to pipes.

Step one is to retrieve your repositories

The GitHub API is paginated. This means it returns results in pages, with at most 100 results per page. If

is less than 100, then you don’t need to worry. If you have more than 100 repositories, you can either choose a page or loop through all pages.

The object my_repos is now a list of repositories. Each element of the list is a particular repository. We are interested in two particular elements: name and fork :

These elements tell us the name of the repository and whether it was created as a result of forking. Now we just repeat this process for all of our repositories and filter to return only the repositories which are forked.

The next step involves manually, and very carefully selecting the repositories you want to delete. If you want to delete all forked repositories (!), simply set

Otherwise, create a vector of repositories to delete

Finally we delete using

And… they’re gone!

Deleting forked repositories like this is an effective way to clean out your GitHub of repositories that you haven’t looked at or touched in a while. However, unlike doing it manually, there is no confirmation where you have to type out a specific repository’s name to confirm that you actually are deleting what you want to be deleting. So, be extremely careful when deleting repositories using as you don’t want to lose hours of work by accidentally running the wrong line.

Читать:
Где хранятся библиотеки python

Похожие статьи