github pulls its own private warehouse (Token method, local secret key method)

github pulls its own private warehouse (Token method, local secret key method)

problem background

In the daily development and learning process, we often encounter the need to pull private warehouse code from GitHub or other similar websites. This article will summarize the two commonly used methods, the Token method and the local secret key method, to facilitate subsequent reference and optimization.

problem solved

1. HTTPS token method

(1) On the GitHub personal homepage, click on the avatar in the upper right corner and select "Settings"
insert image description here

(2) Pull to the bottom and select "Developer settings"
insert image description here

(3) Select "Tokens (classic)" under "Personal access tokens"
insert image description here

(4) Click "Generate new token(classic)" under "Generate new token"
insert image description here

(5) Enter the content and check the options, and click the "Generate token" button at the bottom
insert image description here

(6) Copy the generated token and use the following command to pull the code

git clone https://user:[email protected]/https://github.com/xxxx/xxxx

Note:
(1) TOKEN is replaced with the token just copied;
(2) https://github.com/xxxx/xxxx is replaced with the https pull URL of your own code warehouse

2. Local key method of SSH

(1) git view the current git user name

git config user.name

(2) git set user name

git config --global user.name "xxx"

(3) git view current mailbox

git config user.email

(4) git setting mailbox

git config --global user.email "[email protected]"

(5) Generate the key file and execute the command

ssh-keygen -t rsa -C '[email protected]'

(6) After the execution is completed, the ***_rsa.pub file will be generated under the path: C:\Users\computer user name.ssh\
(7) Then visit and log in to github; click to add ssh-key
insert image description here

(8) In the key, copy the contents of the locally generated id_rsa.pub file to the key input box, and the title can be whatever you want (
9) After the above operations are completed, you can copy the SSH address of the warehouse, and then return to the local to open git bash window, execute the following command to pull the code to the local

git clone 粘贴的ssh路径

Guess you like

Origin blog.csdn.net/weixin_39033300/article/details/132321683