在GitHub上将公共仓库的fork变为私有仓库

摘要

本教程将解释如何在GitHub上将公共仓库的fork变为私有仓库。我们将使用示例代码和GitHub上的操作步骤来说明如何实现这一目标。

内容

在GitHub上,您可以fork公共仓库,并将其变为私有仓库。以下是操作步骤和示例代码:

  1. 首先,按照GitHub的指南,fork一个公共仓库到您的帐户中。

  2. 在GitHub上创建一个空的私有仓库,作为您fork的仓库的副本。

  3. 克隆原始的公共仓库到本地,然后进行配置。

    1git clone --bare https://github.com/exampleuser/public-repo.git
    2cd public-repo.git
    3git push --mirror https://github.com/yourname/private-repo.git
    4cd ..
    5rm -rf public-repo.git
    
  4. 克隆私有仓库到本地,进行修改。

    1git clone https://github.com/yourname/private-repo.git
    2cd private-repo
    3# 进行一些修改
    4git commit
    5git push origin master
    
  5. 如果您想从公共仓库中获取更新,可以使用以下命令:

    1cd private-repo
    2git remote add public https://github.com/exampleuser/public-repo.git
    3git pull public master
    4git push origin master
    

通过按照上述步骤进行操作,您可以将公共仓库的fork变为私有仓库,并进行相应的提交和更新。

总结

在本教程中,我们介绍了如何在GitHub上将公共仓库的fork变为私有仓库。通过使用克隆、修改和推送等Git命令,以及在GitHub上进行相应的操作,您可以成功完成这一过程。

感谢您阅读本教程!

请注意,您需要具有相应的订阅才能创建私有仓库。确保您在进行操作之前具备必要的权限。


相关文章推荐