Local project → Git Bash → Gitee

  • Why Gitee
  • preparation
  • Specific operation
    • There is no local project and you need to create it again
    • Local projects have version control services of their own

Why Gitee

Github links are now blocked in China. Sometimes, even though Ti Zi is very inconvenient, it still cannot pull and push projects normally, which greatly affects the development efficiency. Gitee is a Git-based platform in China, which is very convenient and fast for pull and push. Although the above resources and GitHub are not the same magnitude, but the value of convenience ah. The other is to support the following domestic products, anyway are based on Git, the function is as complete and perfect, now more and more project development is also using Gitee, so here record how to connect gitee in Git bash

preparation

  1. Git has been downloaded
  2. Set up an account with Gitee

Specific operation

There is no local project and you need to create it again

Local itself is an empty folder with no.git and no readme.md. In this case, set up git version control from scratch.

For example, if I create a react-staging empty warehouse/project, I can do the following:



You can continue as follows

Local projects have version control services of their own

The react-create-app plugin can generate a.git for me when I create a project, so I don’t need to create git and initialize git. In order to ensure that the project is uploaded to Gitee safely, it is recommended to create a repository on Gitee. The warehouse name must be the same as the local project name!

Step 1: Create the Gitee repository



Step 2: Create an SSH public key. This step is to ensure that Git can connect to Gitee remotely.

Enter the command:

Ssh-keygen -t rsa-c "email address you used to register gitee" # for example, I use my QQ email addressCopy the code

SSH folder: id_rsa.pub. Open it with notepad and make a copy of the contents.



Go to Personal Settings → Security Settings →SSH public key, copy the code and create a new public key (such as MyGit on my account below).



Step 3: Clear origin Settings for Git bash

This step is to deal with the situation that Git cannot connect to Gitee due to the origin of Github. You can also skip this step if the next steps are ok.

Remote error: no matter how much global Settings are changed in the following process, remote error will be reported, resulting in cannot pull cannot push:



We can get throughgit remote -vCheck to see if the Origin link remains the same on Githubgit remote rm originClear it out and then set the Origin link for the next step.

Step 4: Push according to the prompts after the gITee warehouse is created. After the successful creation of a Gitee warehouse, we will find a lot of guidance codes given by the GITee official. Perform global configuration first :(just copy and paste the official code execution)

Git config --global user.email "git config --global user.email"Copy the code

Now that we’ve created our local project and git version management, we can simply execute the following three sentences.

Git add. # commit change git commit -m Git remote add origin https://gitee.com/ git # push -u origin masterCopy the code

And then you’re done

This article is shared on the blog “Ippo spokesperson Lian Gaobo” (CSDN). If there is infringement, please contact [email protected] to delete. This article participates in “OSC source innovation Program”, welcome you to join us and share with us.