Notes: Process records and common problems of uploading code to remote warehouses such as Gitee

I haven’t used git for a long time, and the instructions are a bit rusty. Today, I uploaded some code to Code Cloud, and first recorded the process for reference by friends who use git. No graphical interface is used, because only by being familiar with the instructions can one truly understand and comprehend.

step one:

1. Install git; after installation, you can use the command git --version to view the version

2. Go to gitee.com to apply for an account, create a new warehouse, and copy the remote warehouse link for backup after it is built, as shown in the figure below:

The link is: https://gitee.com/qinkunming/jjlm.git

Step two:

1. Open a cmd window, enter your own code directory, run the command git init , and generate a local warehouse

 2. Run the command git add --all to add the code in the directory to the local warehouse

3. Run the command git commit -m "note the submitted information by yourself" and submit the added content

 4. Run the command git remote add gitee https://gitee.com/qinkunming/jjlm.git to add a remote warehouse link and add an alias gitee

 

Run the command git push gitee master to upload the main branch master of the local warehouse to the remote warehouse

 

You can see the error above. The reason is that the content in the remote warehouse is inconsistent with the local warehouse. It needs to be pulled to the local to merge the operation.

5. Run the command git pull gitee master to pull the remote warehouse and merge it with the local warehouse

An error is reported in the first pull, because the time is not synchronized, it needs to be merged by force

 Run the command git pull gitee master --allow-unrelated-histories to pull the remote warehouse and force it to merge with the local warehouse. This time it succeeded

 6. Run the command git push gitee master again to upload the main branch master of the local warehouse to the remote warehouse. This time it succeeded

Go to the code cloud to refresh the warehouse status, and the code is updated successfully, as shown in the figure below:

Guess you like

Origin blog.csdn.net/daobaqin/article/details/128122113