Automated Deployment --Git the connection Git remote repository GitHub

First, the remote repository GitHub

GitHub is the largest open source hosting platform designed to promote code hosting, version control and collaboration between individuals working on a common project. I think you can GitHub is a local project file synchronization to the remote, while the modification of the contents of the file downloaded to a local platform at the far end.

Git is a distributed version control system,With a Git repository, it can be distributed to different machines. Initially, only a machine with a primitive version of the library, after which other machines can "clone" of the original version of the library, and each machine repositories are actually the same, there is no distinction between them.

At this point, we need to use GitHub , GitHub provides Git repository hosting services , so long as the registration a GitHub account, you can get free remote Git repository.

1.1 configuration and add a remote repository

1. Create SSH Key.

git config --global user.name "ranran-99"
git config --global user.email "[email protected]"
ssh-keygen -t rsa -C "[email protected]"

Here Insert Picture Description
At this time, found in the user's home directory in the .sshdirectory, there are id_rsaand id_rsa.pubtwo documents, this is the SSH Key secret key pair, id_rsa is private and can not leak out, id_rsa.pub is the public key, can safely tell anyone.

Here Insert Picture Description
2. At this point, the landing GitHub, open SSH and GPG keys. Point " Add SSH Key," fill in any Title, in the Key text box to paste id_rsa.pubthe contents of the file

Here Insert Picture Description

At this point, you can already see already added Key.

Here Insert Picture Description
To verify successful, enter the following command ssh -T [email protected], the following command shows that we have successfully connected to the Github

[root@server6 repository]# ssh -T git@github.com
Hi ranran-99! You've successfully authenticated, but GitHub does not provide shell access.

3, found in the upper right New repositorybutton to create a new warehouse
Here Insert Picture Description

In the Repository name fill in the name of warehouse: repositoryOther keep the default settings, click the Create repositorybutton, you can create a new Git repository.
Here Insert Picture Description

At this point, we can clone a new warehouse from the warehouse, you can put an existing local repository repositoryassociated with it, then pushed to GitHub repository.

Here Insert Picture Description

4, in a local warehouse repositoryto run the command git remote add [shortname] [url], from the local to associate my remote library

  • Virtual machine is available online
git remote add origin git@github.com:ranran-99/repository.git

Here Insert Picture Description
5, all content push local library to a remote database, essentially the current push to remote branch master

git push -u origin master

Here Insert Picture Description6. At this point, you can see in the GitHub page content and local remote databases have been exactly the same

Here Insert Picture Description
7, from now on, as long as the local were submitted, they can command git push origin master, the local last modified pushed to GitHub.

GitHub repository from clone 1.2

1, first create a remote repository Ran1, the default configuration, created after completion, you can see README.md file.

Here Insert Picture Description
2, the command git clonecloning a local library

git clone git@github.com:ranran-99/Ran1.git

Here Insert Picture DescriptionHere Insert Picture Description

In this case, look into the directory, the file has been README.md

Here Insert Picture Description

Published 102 original articles · won praise 21 · views 5315

Guess you like

Origin blog.csdn.net/ranrancc_/article/details/103500282