为 git 仓库设置独立的账户和邮箱
0x01 配置 Git 全局默认的账户和邮箱
1 | # 全局默认的用户名和邮箱 |
0x02 为 git 仓库设置独立的账户和邮箱
使用编辑器打开.git/config
文件,直接在文件的最后添加以下信息:
1 | [user] |
1 | # 全局默认的用户名和邮箱 |
使用编辑器打开.git/config
文件,直接在文件的最后添加以下信息:
1 | [user] |
https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/
Use this section to create a default identity and SSH key when you’re using Git on Windows. By default, the system adds keys for all identities to the /Users/<username>/
.ssh directory.
From the command line, enter ssh-keygen.
ssh-keygen -t rsa -b 4096 -C "email"
List the contents of .ssh
to view the key files.
1 | dir .ssh |
If you don’t want to type your password each time you use the key, you’ll need to add it to the ssh-agent.
1 | eval $(ssh-agent) |
Open your .ssh/id_rsa.pub
file and copy its contents.
From Bitbucket, Paste the copied public key into the SSH Key field. Click Save.
Return to the command line and verify your configuration and username by entering the following command:
1 | ssh -T git@bitbucket.org |
If you used a non-default file path for your GitLab SSH key pair,
you must configure your SSH client to find your GitLab SSH private key
for connections to your GitLab server (perhaps gitlab.com).
For OpenSSH clients this is configured in the ~/.ssh/config
file.
Below are two example host configurations using their own key:
1 | GitLab.com server |
如果使用rsa加密方式,出现秘钥无效,依旧提示输入用户名密码验证,请通过ed25519加密方式,生成ssh秘钥。
ssh-keygen -t ed25519 -C "email" -b 4096
对应生成的私钥 id_ed25519
和公钥 id_ed25519.pub
, 其他配置步骤同rsa生成方式一致。
Git 官方站点: http://git-scm.com/download
1 | # 用户名和邮箱 |
1 | git clone git://github.com/schacon/grit.git |
1 | echo "Git Hand Book" >> README.md |
1 | cd existing_folder |
1 | cd existing_repo |
Update your browser to view this website correctly.&npsb;Update my browser now