Manage and use Git remote Repository

Source: Internet
Author: User

Manage and use Git remote Repository

Git is a distributed version control system. The same Git repository can be distributed to different machines. How is the distribution? At the earliest, only one machine must have an original version library. After that, other machines can "clone" the original version library, and the version libraries of each machine are actually the same, there is no primary or secondary division.

You will surely think that at least two machines are required to play the remote database, isn't it? But I only have one computer. How can I do it?

In fact, multiple version libraries can be cloned on a computer, as long as they are not in the same directory. However, in real life, no one is so stupid to engage in several remote libraries on a computer, because it is meaningless to engage in several remote libraries on a computer, in addition, the hard disk will cause all the databases to be down, so I won't tell you how to clone multiple warehouses on one computer.

This is often the case. Find a computer to act as a server and start up 24 hours a day. Everyone else clones a copy from this "server" warehouse to his computer, in addition, they push their respective commits to the server warehouse and pull others' commits from the server warehouse.

You can build a server to run Git on your own. However, at this stage, it is absolutely difficult to build a server to learn Git. Fortunately, there is a magical website called GitHub in this world. It can be seen from its name that this website provides the Git repository hosting service. Therefore, you only need to register a GitHub account, you can get the Git remote repository for free.

Register Your GitHub account before continuing to read the subsequent content. Because the transmission between your local Git repository and GitHub repository is encrypted by Using SSH, you need to set the following settings:

Step 2: Create an SSH Key. In the user's main directory, check whether there is a. ssh directory. If so, check whether there are id_rsa and id_rsa.pub files in this directory. If there are already two files, you can directly jump to the next step. If no, Open Shell (Open Git Bash in Windows) and create an SSH Key:

$ Ssh-keygen-t rsa-C youremail@example.com

You need to replace the email address with your own email address and press enter to use the default value. Because this Key is not used for military purposes, you do not need to set a password.

If everything goes well, you can find it in the user's home directory.sshDirectory, which containsid_rsaAndid_rsa.pubTwo files, which are the Key pair of the SSH Key,id_rsaIt is a private key and cannot be disclosed,id_rsa.pubIt is a public key. You can tell anyone with confidence.

Step 2: log onto GitHub and open the "Account settings" and "SSH Keys" pages:

Click "Add SSH Key", fill in any Title, and paste it in the Key text box.id_rsa.pubFile Content:

Click "Add Key" to view the added Key:

Why does GitHub need an SSH Key? Because GitHub needs to identify that the submission you push is indeed pushed by you, rather than impersonating others, and Git supports the SSH protocol, GitHub only needs to know your public key, you can confirm that only you can push.

Of course, GitHub allows you to add multiple keys. Assume that you have several computers. If you submit them at the company and submit them at home later, you only need to add the keys of each computer to GitHub, you can push data to GitHub on each computer.

Finally, the Friendly reminder is that anyone can see the free Git repository hosted on GitHub (but only you can change it ). Therefore, do not include sensitive information.

If you don't want others to see the Git repository, there are two ways: one is to pay the protection fee and let GitHub convert the public repository to private, in this way, others will be invisible (neither readable nor writable ). Another method is to build a Git server by yourself. Because it is your own Git server, no one else can see it. This method is quite simple and necessary for internal development.

Make sure that you have a GitHub account and we are about to start learning from remote warehouses.

Summary

"With a remote warehouse, Mom no longer needs to worry about my hard disk ." -- Git point Reader

GitHub Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

GitHub details: click here
GitHub: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.