git finishing (c)

Git (c)

Remote repository

So far, all of our operations are managed in a local repository version, which can also be used in svn, have said before git, there is a need to act only on the exchange of pseudo central warehouse, but when you have only one computer how to do, to build two repositories? Of course you can, in fact, a computer also can clone multiple versions of the library, just not in the same directory. However, in real life no one is silly to engage in some remote library to play on a computer, as do several remote libraries on a computer completely meaningless, and hung up the hard disk will cause all libraries are hung, so I do not tell you how to clone multiple repositories on a single computer. 
The reality is often the case, find a computer acting as a server role, 24 hours a day, everyone else from this "server" Warehouse cloned copy to your own computer, and each put their submissions pushed to the warehouse server also pulled from the server to submit someone else's warehouse.
You can build their own a computer running Git server, but at this stage, in order to learn to take a Git server is definitely a fuss. Fortunately, a man named GitHub magical site in the world, can be seen from the name, this site is provided Git repository hosting services, so long as the registration a GitHub account, you can get free remote Git repository.
There can build a remote repository called "code cloud," cloud nor that of course this code Ma, both operations are similar.
Of course, it is a registered account.

Public and private keys

Private: a private key, only the user will do. 
Public: a public key, the public offering and distribution, as long as the requirements that is achieved.
Each key is used to generate an attribute change functions. Private key to generate a private property to change the function, and open public key to produce a change in functional properties. These functions are inversely related, for example, if the function is used to encrypt a message, additional features were used to decrypt a message. Why this change regardless of the order neither important attribute function. The key advantages of open systems is that two users can communicate without security of secret key exchange. For example, suppose a messenger who need to send a message to a list of recipients, and secret information is necessary, messenger in a public key to encrypt recipients, while the private key is only recipients can decrypt this information . Public key cryptography is well suited to provide authentication, integrity and service can not be denied, that is, all of these services we know the digital signature.
The public and private key principles:
1: a public key corresponding to a private key.
2: key pair, let everyone know that the public key, not to tell you, only you know, is the private key.
3: If the data encrypted with one key, the only key that can decrypt the corresponding.
4: If one of the keys can decrypt the data, the data must be the encryption key corresponding to that performed. Since the transmission between your local Git repository and warehouse code cloud is through SSH encryption, so take a little setup: create SSH Key. In the user's home directory to see if there .ssh directory, if there is, and then see if there id_rsa and id_rsa.pub these two files in this directory, if you already have, you can jump directly to the next step. If not, open the Shell (Open under Windows Git Bash), create Key SSH: $ SSH-keygen -t rsa -C "your email address" following the carriage return line







Why GitHub SSH Key needs it? Because GitHub need to identify your submission is indeed push you push, rather than posing as someone else, and Git support SSH, so, as long as GitHub know your public key, you can confirm that only you can push.

Cloud remote code repository

After registration, the above user interface is a visual interface, very simple. 
Creating a remote repository
to add in front of the public key to the remote warehouse (public storm drain out do not worry, all public and private key pairs, a private key must be kept.)
There are from a remote repository associated with the local warehouse two kinds HTTPS and SSH protocols way

HTTPS

In the local project in the right-bash here Wallpaper git 
$ git clone [email protected]: z7z8l78z / test.git
will bring down the project clone
clone while the project will bring the project to establish a local warehouse, and directly connected to the remote repository
If you do not believe that there is no connection command remote repository can use the following
$ git remote -v
If you see corresponds url appear, under normal circumstances are corresponding
this time the project operation, you can submit to a remote repository
submission process
add to the cache git the Add a.txt District $
the commit to the commit -m local git repository $ "commit1"
the Push to remote repository $ git push -u origin master

Directly linked to a remote repository from a local warehouse

# Associated with the remote repository 
$ git remote add origin url remote repository if you accidentally linked to the wrong Zaban, do not panic # delete the associated git Remote RM Origin # longer associated with the new address git remote add origin url remote repository





 

Guess you like

Origin www.cnblogs.com/liudongshuai/p/11574180.html