Introduction to Git

Project maintenance - > getting started with Git

    As a newcomer, Xiaobai knows very little about the code maintenance of the projects he works with, and there are many tools introduced by the leaders around him: git,gitken,sourcetree Wait, I feel that I remember after the operation. There are still some differences in my own operation in the later stage. Recently, I saw a clear and convenient operation process, which is recorded here

Note: the operation steps are based on the installation of Git, gitlab or github

Specific steps for connecting the local warehouse to the cloud:

1. Right click gitbush to enter the command line window

2. Obtain SSHKey
First, create an ssh key locally. The purpose of this is that you now need to obtain a key on your computer.

Generate sshkey with the following command:

$ ssh-keygen -t rsa -C ""  

# Generating public/private rsa key pair...
# Press enter three times to generate ssh key

Check your public key,

$ cat ~/.ssh/
# ssh-rsa AAAAB3NzaC1yc2E...

And add it to Gitee ( SSHKey add address) or GitHub ( SSHKey add address)

After adding, enter in the terminal

$ ssh -T

$ ssh -T

When Binding for the first time, you will be prompted whether to continue after entering the above code. After entering yes, the program will automatically connect. If login is required, you can directly enter the login information.

Execute the above command again to check whether the connection is successful. If the following information is returned, it indicates that the addition is successful

#Gitee``Welcome to, YourName!` `#GitHub``You've successfully authenticated, 
but GitHub does not provide shell access.

3. Set basic information

$ git config --global "yourname"
$ git config --global ""

Email must be the email used for code cloud or GitHub registration. Commands are not sequential.

4. Initialize local warehouse
Then clone your remote warehouse locally, or you can initialize a project locally and then bind to the cloud.

$ git clone

$ git clone

#yourname is the user name you registered in the code cloud or github
#Repository is the name of the remote repository you created

Local initialization

$ cd d:/test //First create a project folder in the file system, and then cd it to the project directory in Git
$ git init //Initialize local project
$ git remote add origin <Remote warehouse address> //Bind remote warehouse
#Note: the address form is Or

$ cd d:/test
$ git init
$ git remote add origin <Remote warehouse address>#Note: the address form is

Update to remote warehouse
After editing locally, update to the remote warehouse

git add .    //Specify what to update Indicates all updates, test Txt means to update the specified file
git commit -m "Some notes"     //Add update description
git push origin master            //Perform update operation

During the update operation, the program responds slowly because it needs to verify the user information of the remote warehouse. Don't think Git Bash is dead

If it is the first update, the following window may pop up, enter your user name and password, and click login.

If this happens during subsequent update operations, it means that the login failed. You need to re record your user information and enter your user name and password again to log in

Logon failed, use ctrl+c to cancel basic credential prompt.
Username for ''

How to synchronize the latest version from the remote warehouse to the local

$ cd d:/test
$ git pull origin master

Clear screen

$ clear

reference resources:

Added by websteve on Wed, 22 Dec 2021 05:51:41 +0200