主要通过给GitHub设置SSH key的方式实现push权限控制。
$ ssh-keygen -t rsa -C "你的邮箱" Generating public/private rsa key pair. //这里指定秘钥文件路径,直接回车即可 Enter file in which to save the key (/c/Users/my/.ssh/id_rsa): Created directory '/c/Users/my/.ssh'. //输入登录密码 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/my/.ssh/id_rsa Your public key has been saved in /c/Users/my/.ssh/id_rsa.pub The key fingerprint is: SHA256:xxxxxexample@gmail.com The key's randomart image is: +---[RSA 3072]----+ | .o...=o. | | .. =.. | | ..oE . | | oo O | | S B.+ B | | * O * + | | o = B X o .| | . + = X = | | o.o = | +----[SHA256]-----+
在上面路径的id_rsa.pub中得到公钥(全部复制)
然后进入gitHub中,找到Setting
SSH keys / Add new