4. git configure Gitee remote specified warehouse and submit the code

1. The first step: first create a remote warehouse

insert image description here
After clicking Create , the following interface will be displayed, and the place pointed by the arrow is the remote address of the currently created warehouse:
insert image description here

2. Step 2: Configure SSH public key

First open git bash and enter the following command on the command line:

ssh-keygen -t ed25519 -C "[email protected]" 

The above mailbox can be specified at will, there is no specific requirement, after executing the command, click the Enter key three times according to the prompt to generate the public key
Enter the following command to view the public key:

cat ~/.ssh/id_ed25519.pub

Copy all the displayed strings, then click your avatar on the gitee official website to select settings , find the following interface and add the copied public key:
insert image description here
After adding, enter the following command in the terminal:

ssh -T git@gitee.com

For the first use, you need to confirm and add the host to the local SSH trusted list. If the content Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access. is returned, it proves that the addition is successful.
insert image description here
After that, the warehouse can be operated

3. Step 3: Initialize the local warehouse

Enter the folder where the code is located, right-click in the blank space of the folder, and select Git Bash Here to open the git command line terminal, as shown in the figure below:
insert image description here
If the current folder has not been created as a local warehouse, you can enter in the command line terminal *** git init ***, initialize the current folder as a local warehouse, and then use the following command to configure the user name and mailbox globally:

git config --global user.name "自己的用户名"
git config --global user.email "自己的邮箱"

Then add the following address of the remote warehouse just created:

git remote add origin(远程仓库别名) 远程仓库地址

4. Step 4: Submit the code to the remote warehouse for the first time

Then create a REANME.cmd file, try the first remote

touch README.cmd

Add files to be submitted to the cache

git add README.cmd
git commit -m "first commmit"

Push files to remote warehouse

git push -u origin master //第一次推送使用这个命令(推送的同时也会将远程仓库于本地仓库进行关联)
git push  // 以后再次推送,可以使用这个命令直接进行推送

5. The local warehouse changes the bound remote warehouse

Sometimes it is necessary to push the code of the local warehouse to other remote warehouses. At this time, the remote warehouse bound to the local warehouse can be changed
using the following command:

git remote set-url origin 新的仓库地址

6. Tips:

  1. The second way to change the remote warehouse:
git remote rm origin(远程仓库别名) //先将当前关联的远程仓库删除
git remote add origin 新的远程仓库地址 //再添加新的远程仓库地址,别名还是origin

Continuously updating, please pay more attention to...

Guess you like

Origin blog.csdn.net/FY_13781298928/article/details/129800813