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 "youremail@youremail.com" # Generating public/private rsa key pair... # Press enter three times to generate ssh key
Check your public key,
$ cat ~/.ssh/id_rsa.pub # ssh-rsa AAAAB3NzaC1yc2E... youremail@youremail.com
And add it to Gitee (gitee.com SSHKey add address) or GitHub (github.com SSHKey add address)
After adding, enter in the terminal
#Gitee $ ssh -T git@gitee.com #GitHub $ ssh -T git@github.com
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 Gitee.com, YourName!` `#GitHub``You've successfully authenticated, but GitHub does not provide shell access.
3. Set basic information
$ git config --global user.name "yourname" $ git config --global user.email "youremail@youremail.com"
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.
clone
#Gitee $ git clone https://gitee.com/yourname/repository #Github $ git clone https://github.com/yourname/repository.git #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
#Gitee $ 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 https://gitee.com/yourname/test.git Or git@gitee.com:yourname/test.git #Github $ cd d:/test $ git init $ git remote add origin <Remote warehouse address>#Note: the address form is https://github.com/yourname/test.git
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 'https://githun.com'
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: https://www.cnblogs.com/shimmernight/p/13558705.html