我是其他人设置的私人存储库的协作者,如何在我的个人资料中公开它?



当我们在做一个学校项目时,我的队友为它设置了一个私有的repo。它被认为是我们课程的作品集项目,所以我们被允许在课程结束后分享它,但我的队友从未改变过可见性。我想让它在我的GitHub配置文件中可见,以便潜在的雇主在我申请工作时可以看到它。

我试过分叉它,但是这个分叉也是私有的,我没有办法改变它。所以我创建了一个新的公共仓库,克隆了一个私人仓库,并把它推送到我的新公共仓库。这在一定程度上起作用-代码在那里,并有所有提交的历史记录,但它不显示分支,拉取请求等,我希望理想情况下保留,这样你就可以看到我所有的贡献。

假设我不再有办法联系我的队友,让他将原始的repo设置为public,是否有更好的方法来处理这个问题?

联系方式:

  • Git默认需要一个email
  • GitHub允许提及与@username的人

打开git log并检查电子邮件,或从无回复模式中收集电子邮件地址,或在私有repo中创建新问题并提及队友。

你的队友应该在git配置(电子邮件)或GitHub配置文件中有一些有用的设置,因此你应该能够联系到。如果没有,试着和老师/讲师谈谈。如果还是没有成功,那我们就进入技术部分吧。

让我们从在机器上复制这种情况开始:

  1. 你的队友创建了一个repo,不知何故,我们将做最简单的情况:
/tmp$ mkdir folder && pushd folder
# /tmp/folder /tmp
/tmp/folder$ mkdir original-repo && pushd original-repo
# /tmp/folder/original-repo /tmp/folder /tmp
/tmp/folder/original-repo$ git init
# Initialized empty Git repository in /tmp/folder/original-repo/.git/
  1. 添加了一些提交,分支,标签:
/tmp/folder/original-repo$ git commit -m initial --allow-empty
# [master (root-commit) 98f9b79] initial
/tmp/folder/original-repo$ git tag mytag
/tmp/folder/original-repo$ git checkout -b new-branch
# Switched to a new branch 'new-branch'
/tmp/folder/original-repo$ git commit -m new-commit --allow-empty
# [new-branch 8839b1a] new-commit
/tmp/folder/original-repo$ git checkout master
# Switched to branch 'master'
/tmp/folder/original-repo$ popd
# /tmp/folder /tmp
  1. push到某处:
# how a repo is created via GitHub, cca
/tmp/folder$ mkdir remote-original-repo && pushd remote-original-repo
# /tmp/folder/remote-original-repo /tmp/folder /tmp
/tmp/folder/remote-original-repo$ git init --bare
# Initialized empty Git repository in /tmp/folder/remote-original-repo/
/tmp/folder/remote-original-repo$ git branch -a
# <nothing>
/tmp/folder/remote-original-repo$ pushd ../original-repo/
# /tmp/folder/original-repo /tmp/folder/remote-original-repo /tmp/folder /tmp
/tmp/folder/original-repo$ git remote add origin ../remote-original-repo
/tmp/folder/original-repo$ git push --all && git push --tags
# Enumerating objects: 3, done.
# Counting objects: 100% (3/3), done.
# Delta compression using up to 4 threads
# Compressing objects: 100% (2/2), done.
# Writing objects: 100% (3/3), 257 bytes | 257.00 KiB/s, done.
# Total 3 (delta 1), reused 0 (delta 0)
# To ../remote-original-repo
#  * [new branch]      master -> master
#  * [new branch]      new-branch -> new-branch
# Total 0 (delta 0), reused 0 (delta 0)
# To ../remote-original-repo
#  * [new tag]         mytag -> mytag
/tmp/folder/original-repo$ popd
# /tmp/folder/remote-original-repo /tmp/folder /tmp
/tmp/folder/remote-original-repo$ git branch -a && git tag -l
# * master
#   new-branch
# mytag
/tmp/folder/remote-original-repo$ popd
# /tmp/folder /tmp

现在的情况是:

  1. 你已经创建了你的克隆
/tmp/folder$ git clone remote-original-repo local-clone
# Cloning into 'local-clone'...
# done.
/tmp/folder$ pushd local-clone/
# /tmp/folder/local-clone /tmp/folder /tmp
/tmp/folder/local-clone$ git branch -a && git tag -l
# * master
#   remotes/origin/HEAD -> origin/master
#   remotes/origin/master
#   remotes/origin/new-branch
# mytag

(Git默认会拉出所有的分支,但不会标记它们用于跟踪!)

  1. 在远程位置创建repo并推送分支(即仅本地分支)
/tmp/folder/local-clone$ popd
# /tmp/folder /tmp
/tmp/folder$ mkdir remote-cloned-repo && pushd remote-cloned-repo
# /tmp/folder/remote-cloned-repo /tmp/folder /tmp
/tmp/folder/remote-cloned-repo$ git init --bare
# Initialized empty Git repository in /tmp/folder/remote-cloned-repo/
/tmp/folder/remote-cloned-repo$ git branch -a && git tag -l
# <nothing>
/tmp/folder/remote-cloned-repo$ pushd ../local-clone/
# /tmp/folder/local-clone /tmp/folder/remote-cloned-repo /tmp/folder /tmp
/tmp/folder/local-clone$ git remote add my-fork ../remote-cloned-repo
/tmp/folder/local-clone$ git push --all my-fork 
# Enumerating objects: 2, done.
# Counting objects: 100% (2/2), done.
# Writing objects: 100% (2/2), 179 bytes | 179.00 KiB/s, done.
# Total 2 (delta 0), reused 0 (delta 0)
# To ../remote-cloned-repo
#  * [new branch]      master -> master
/tmp/folder/local-clone$ popd
# /tmp/folder/remote-cloned-repo /tmp/folder /tmp
/tmp/folder/remote-cloned-repo$ git branch -a && git tag -l
# * master
# where is the rest?

但不是所有的东西都被推了。使用git,您也可以在本地获得所有分支和标记,但它们不会自动推送,因此您还需要从克隆中使用--all--tags:

那么如何从这里开始呢?

  1. origin中的所有远程分支跟踪为本地分支
/tmp/folder/remote-cloned-repo$ pushd ../local-clone/
# /tmp/folder/local-clone /tmp/folder/remote-cloned-repo /tmp/folder /tmp
/tmp/folder/local-clone$ for ref in $(git for-each-ref --format='%(refname:short)' --no-merged=origin/HEAD refs/remotes/origin);do git checkout -b $(echo "$ref"|sed -e 's,origin/,,') --track "$ref";done
# Branch 'new-branch' set up to track remote branch 'new-branch' from # 'origin'.
# Switched to a new branch 'new-branch'
  1. 再次将所有内容推送到fork远程存储库
/tmp/folder/local-clone$ git push --all my-fork 
# Enumerating objects: 1, done.
# Counting objects: 100% (1/1), done.
# Writing objects: 100% (1/1), 202 bytes | 202.00 KiB/s, done.
# Total 1 (delta 0), reused 0 (delta 0)
# To ../remote-cloned-repo
#  * [new branch]      new-branch -> new-branch
/tmp/folder/local-clone$ git push --tags my-fork 
# Total 0 (delta 0), reused 0 (delta 0)
# To ../remote-cloned-repo
#  * [new tag]         mytag -> mytag
/tmp/folder/local-clone$ popd
# /tmp/folder/remote-cloned-repo /tmp/folder /tmp
/tmp/folder/remote-cloned-repo$ git branch -a && git tag -l
# * master
#   new-branch
# mytag
  1. (可选)删除你的克隆/创建一个新的克隆,这样你就不需要在拉/推时玩不同的起源

关于GitHub存储库数据。简单的答案是-NO. 一个更好的答案是将它复制粘贴到新的存储库中,同时拉取请求和问题,但是链接到仓库的相关关系和合并已经被破坏了。如果你只关心内容,它仍然是可用的。对于可伸缩性,请使用API。

还要注意(上的锡纸帽),存储库有法律方面的问题,比如当前的许可证,你的队友提交的代码等,所以确保你在那里被覆盖,或者通过电子邮件请求许可,并将许可存储在安全的地方。

最新更新