How do I configure repo on GitHub so that everyone can see it, but I can select people who can make changes?

huangapple go评论74阅读模式
英文:

How do I configure repo on GitHub so that everyone can see it, but I can select people who can make changes?

问题

我想知道如何创建一个存储库,以便理想情况下它显示在我的个人资料上(所以我想它必须是公开的),但除了我选择的几个人以外,没有人可以推送和提出拉取请求。

我之所以想设置成这样,是因为我正在与朋友一起制作一款可能会出现在Steam上的游戏,我担心如果我们决定出售它,外部的某人推送自己的更改到该存储库,那么我们将不再拥有该项目的100%所有权/版权。
我知道我可以将其设置为私有,并添加我的朋友作为合作者,但我也在寻找游戏开发工作,希望将该项目作为我的作品集的一部分。

我尝试创建一个公共存储库,并添加合作者,但它没有阻止非合作者(这些非合作者是我用来推送更改的备用帐户。为确保GitHub将它们视为独立帐户,我在本地存储库的配置文件中更改了user.name和user.email,然后推送了更改)推送到主分支。甚至将它们添加为贡献者。

如您所见,Bebzon123 是一位贡献者

我使用以下bash命令推送更改

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo
$ git clone https://github.com/MichalNawrocki77/collab-test.git
克隆到 'collab-test'...
远程:正在枚举对象:3,完成。
远程:计算对象:100%(3/3),完成。
远程:总共3个(增量0个),重复使用3个(增量0个),pack-reused 0
接收对象:100%(3/3),完成。

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo
$ cd collab-test

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git config user.name MichalNawrocki187

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git config user.email michalnawrocki187@gmail.com

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git add .

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git commit -m"non-collaborator's commit"
[master 43bfc8d] non-collaborator's commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 non collaborator file.txt

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git push origin master
正在枚举对象:3,完成。
计数对象:100%(3/3),完成。
Delta使用多达16个线程进行压缩
压缩对象:100%(2/2),完成。
写入对象:100%(2/2),276字节| 276.00 KiB/s,完成。
总共2个(增量0个),重复使用0个(增量0个),pack-reused 0
https://github.com/MichalNawrocki77/collab-test.git
   efc8dd2..43bfc8d  master -> master

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ 

现在 MichalNawrocki187 是贡献者,尽管他不是合作者,最糟糕的是他推送更改而没有提出拉取请求

英文:

I want to know how to make a repository so that ideally it shows up on my profile (so it has to be public I guess), but no one except for a few people I select can push and make pull requests

The reason why I want this to be set up like this is because I'm making a game with my friends that may end up on steam and I'm worried that if we do decide to sell it, and somebody from the outside pushes his own changes to that repo we will no longer have 100% ownership/copyright of that project.
I know I could just make it private, and add my friends as collaborators, but I'm also looking for a game dev job and would like to have that project as a part of my portfolio.

I tried making a public repo, and add collaborators, but it didn't stop non-collaborators (which were my alternate accounts with which I pushed the changes. To make sure that GitHub sees them as seperate accounts I changed user.name and user.email in my local repository's config file before pushing) to push to main. It even added them as contributors.

as you can see Bebzon123 is a contributor

I used these bash commands to push changes

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo
$ git clone https://github.com/MichalNawrocki77/collab-test.git
Cloning into 'collab-test'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo
$ cd collab-test

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git config user.name MichalNawrocki187

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git config user.email michalnawrocki187@gmail.com

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git add .

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git commit -m"non-collaborator's commit"
[master 43bfc8d] non-collaborator's commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 non collaborator file.txt

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 276 bytes | 276.00 KiB/s, done.
Total 2 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/MichalNawrocki77/collab-test.git
   efc8dd2..43bfc8d  master -> master

Zibzą77@DESKTOP-DTPUJI4 MINGW64 ~/Desktop/non collaborator repo/collab-test (master)
$ 

and now MichalNawrocki187 is a contributor even tho he is not a collaborator, and worst of all he pushed changes without making pull requests

答案1

得分: 1

你所做的很好(一个公共仓库并管理你想提供推送权限的合作者)。

只是你的测试是错误的,因为更改user.nameuser.email与身份验证(和推送访问权限)无关。这只是Git在创建提交时用于显示信息的,是GitHub用来区分仓库的合作者的信息,是的,你可以设置任何愚蠢的信息。

你的凭据第一次推送到GitHub时肯定会被要求,并由Git存储在凭据管理器中,以后会自动在推送新提交时使用。

顺便提一下:你无法阻止拉取请求,因为只要你的仓库是公共的,任何人都可以分叉并在其分叉的仓库上工作,并且如果他想帮助你,就可以发起拉取请求。但这并不是什么大问题,因为最终是你决定是否要合并PR,从而包括这些提交。如果你不想要,只需关闭PR,并友好地解释为什么不接受贡献。

注意:要使用另一个帐户进行真正的身份验证测试,要么从另一台计算机进行,要么从凭据管理器中删除凭据,以便Git再次要求它们...

英文:

What you did is good (a public repo and managing the collaborators you want to provide push right).

It's just your test that is wrong because changing the user.name and user.email has nothing to do with the authentication (and push access right). It's just a display information used by git when you create commits (and yes these information are used by Github to distinguish collaborators of a repository and yes again you could set whatever dumb information you want).

Your credentials have surely been asked to you the first time you pushed to Github and stored by git in the credential manager and later automatically used when you pushed new commits.

Side note: you can't prevent pull requests because as long as your repository is public everybody could fork and working on its forked repository and do a pull request if he wants to help you. But it's not a big deal because in the end that's you that decide if you want to merge the PR and so include the commits. If you don't want, you just have to close the PR with a friendly comment explaining why you don't accept contribution.

Note: to do a real authentication test with another account, either do it from another computer or remove credentials from credential manager so that git ask them again...

huangapple
  • 本文由 发表于 2023年7月28日 02:11:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76782415.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定