“This is the 10th day of my participation in the First Challenge 2022. For details: First Challenge 2022.”
The vast sea of millions, thank you for this second you see here. I hope my article is helpful to you!
May you keep your love and go to the mountains and seas in the coming days!
Inscription: 😎 today we come to learn new knowledge! Before we understand the concept of remote warehouse, so today we need to learn how to create a remote warehouse? Yes, today let’s learn how to create it!
🍎 code cloud usage
🍏 official website:
Website: gitee.com
🍐 Register an account
Can’t sign up? Don’t panic! In order to serve the people, here I will also tell you how to operate in detail:
Hey hey 😊, mother no longer worry that I will not register code cloud account! In this way, we got our own code cloud account!
After successful registration, the home page is displayed
🍑 Create a remote repository
Once you have registered your account, the next step is to create the repository.
At this point, your remote repository is declared complete. Did you suddenly have a remote warehouse, very happy. But how do you add a remote repository?
🍒 Add a remote repository
Without further ado, let’s look at two ways to add a remote repository:
Our local computer and remote server can use two ways to transfer data :HTTPS and SSH.
The HTTPS protocol requires you to enter the account password when pushing the code. You only need to configure the SSH protocol once. You do not need to enter the account password. So, we learn to SSH (lazy is a great word for human development).
-
What is the SSH protocol
SSH is short for Secure Shell and formulated by the Network Working Group of the IETF. SSH is a reliable protocol that provides security for remote login sessions and other network services. The SSH protocol can effectively prevent information leakage during remote management.
When SSH is used for communication, key-based authentication is recommended. So you have to create a pair of keys for yourself, and you need to put the public key on the remote repository.
-
Create a SSH key
First of all, we can under the user home directory, see if there are any. SSH directory, if you have, to see if this directory is id_rsa and id_rsa pub these two files, if have, can be directly jump to the next step. If not, right-click Git Bash in the folder to go to CMD, create an SSH Key, and enter the command
$ ssh-keygen -t rsa Copy the code
Enter all the way down press Enter three times without typing anything!
If all goes well, you can find id_rsa and id_rsa.pub in C:\Users\ username.ssh, which are the Key pairs for SSH keys.
Note: ID_rsa is a private key and cannot be disclosed 😳, id_Rsa. pub is a public key and can be safely told to anyone. 💪
-
-
Code cloud SSH key configuration
-
Step 1: Then copy the contents of the public key file [id_rsa.pub] generated by C:\Users\Saturn. SSH.
-
Step 2: Open gitee’s official website — [Login] — [Settings] – [SSH public Key] options as shown below:
Note that after clicking OK, you will need to perform an account security verification by entering your password for the code cloud login.
-
When you’re done, this screen should appear:
This means that your public key has been added. Here’s why we need to add this SSH Key, or why the code cloud needs this SSH Key. Because the code cloud needs to know that the submission you are pushing is really your own, and not someone else’s, and Git supports SSH, the code cloud can confirm that only you can push as long as it knows your public key.
Of course, the code cloud allows you to add multiple keys. Suppose you have a number of computers, and you submit them at work or at home. As long as you add the Key of each computer to the code cloud, you can push them to the code cloud from each computer.
-
-
After adding the public key successfully, we started adding our remote repository
After completing the previous operations, make sure that your code cloud has an account, you have your own COMPUTER SSH Key, and you have a remote repository.
-
Find the remote repository TestGit we created earlier and produce the SSH address of the code cloud:
-
Through the code cloud, we can add remote warehouses and associate local warehouses with them
Now we can associate an existing local repository with it and push the content from the local repository to the GitHub repository.
-
Now let’s copy the SSH protocol address above as prompted by the code cloud and run the command from the local repository:
git remote add origin [email protected]:fish-best/test-git.git Copy the code
Please pay attention to 🟡🟡🟡, replace [email protected]:fish-best/test-git.git with your own SSH protocol address, otherwise, you are associated with my remote library locally, there is no problem with association, but you will not be able to push it later. Because your SSH Key is not in my account list, and it does not push your own remote repository.
The name of the remote repository will be Origin, which is Git’s default name and can be changed to something else, but origin is clearly the name of the remote repository.
-
Now we have associated the remote repository, but the remote repository has no content, now we need to push all the content of the local repository to the remote repository:
$ git push -u origin "master" Counting objects: 9, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (9/9), 811 bytes | 811.00 KiB/s, done. Total 9 (delta 0), reused zero (0) delta remote: GITEE.COM [gnk-6.2] To GITEE.COM :fish-best/test-git. Git * [new branch] master -> Master branch master set up to track remote branch master from origin.Copy the code
If you need to enter yes, just type yes!
Git push git push git push git push git push git push
Git will not only push the contents of the local master branch to the new remote master branch, but also associate the local master branch with the remote master branch, which can simplify the command in the future push or pull.
-
After the push is successful, you can immediately see the content of the remote warehouse is exactly the same as that of the local in the code cloud page:
-
From now on, whenever a change is committed locally, you can run the following command:
$ git push origin master Copy the code
Push the latest changes from your local master branch to the code cloud, and you now have a truly distributed version library! Are you excited?
-
Here’s one thing to watch out for: SSH warnings
The first time you use Git’s Clone or push command to connect to a remote repository, you get a warning:
The authenticity of host 'gitee.com (xx.xx.xx.xx)' can't be established. RSA key fingerprint is xx.xx.xx.xx.xx. Are you sure you want to continue connecting (yes/no)? Copy the code
This is because Git uses SSH connection, and when SSH connection authenticates the Key of the code cloud server for the first time, you need to confirm whether the fingerprint information of the Key of the code cloud really comes from the server of the code cloud. Enter yes and press Enter.
Git will print a warning telling you that a Key from the code cloud has been added to a local trust list:
Warning: Permanently added 'gitee.com' (RSA) to the list of known hosts. Copy the code
This warning will only occur once, and subsequent operations will not have any warning.
-
-
Here’s a summary of adding a remote repository:
- To associate a remote library, use the command
Git remote add Origin SSH protocol
; - After the association, run the command
git push -u origin master
Push all contents of the master branch for the first time - After that, commands can be used whenever necessary after each local commit
git push origin master
Push the latest modification; And one of the biggest advantages of the distributed version of the system is that the local work does not need to consider the existence of remote library, that is, whether or not the Internet can work normally, and SVN in the absence of Internet is refused to work! When the network is available, it is convenient to push the local submission to complete the synchronization.
- To associate a remote library, use the command
🌸 summary
I believe that you see here, today’s git tutorial should be simple for you! Today we know how to create a remote warehouse, also created a code cloud account, later you want to submit their own good code to the code cloud, remember open source and share out yo, 🧐 respect open source, respect original 🤛!!
Let’s refuel together, too! I am not just, if there is any missing, wrong place, also welcome you to criticize in the comments of talent leaders! Of course, if this article is sure to help you a little bit, please kindly and lovely talent leaders give a thumblike 👍, save it, and welcome to follow ❤️❤️❤️ [favorite food of canned fish] 👍, thank you very much! If you like canned fish too! 💕 💕 💕
Here, the world is closed for today, good night! Although this article is over, I am still here, never finished. I will try to keep writing articles. The coming days are long, why fear the car yao ma slow!
Thank you all for seeing this! May you live up to your youth and have no regrets!