Since yesterday began to look at the use of git, because many command-line operations in Windows compared to the pit father, but today after a lot of detours and finally completed the GIT local warehouse and Remote Warehouse Association, recorded as follows,
First thanks to the http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 of Liao's blog,
And thanks to this friend Http://blog.baibaobing.com/other/99.html's record to help me solve the problem.
The text begins,
I'll combine an example to introduce:
Of course, before you use git, download the git client link here: http://git-scm.com/download/
There is no GitHub for Windows here because I think the more biased door, not too pervasive, I would not be able to under the Linux.
Describe GitHub and git first:
1.git is a version of a control system, BlaBla describes what the least likes .....
That is, we use git to manage our code, then we need to add the code to the Git repository, Git has a concept of a local repository, that is, you can record changes locally to adapt to an environment that is not networked.
2. The remote repository is similar to the current network on the remote host, but with the functionality of Git, you can save our code base on the host. GitHub here is the remote repository.
First of all, we need to use the remote repository now GitHub registered account, how to register not much to say.
Then we need to create a local repository locally, which is where you need to build the repository to execute the command:
Git init
Example:
Create a new Learngit folder under the user directory, using the above command in this folder:
Open git bash
The local warehouse completion is initialized at this time.
We're going to add a file in there, and before we do, we need to set up a global user so that git knows who you are so you can record every change you make to the warehouse.
The main is to set the user name and mailbox, using the following command
" yourname " "your email addr"
The name and mailbox are not required to be registered with GitHub.
I set it up like this:
Add a file below to this folder (should call the local repository)
Note that the file that is added to the warehouse at this time is not in the warehouse because it is not in the warehouse record.
Add the file to the warehouse (record) using the following command:
git add filename
I have added a readme.md file here under the Learngit ask price clip:
This creates a local repository.
The following is the establishment of the remote repository, because to upload the need to associate the local warehouse and remote warehouse;
Start a new warehouse on GitHub:
Note that the warehouse name here does not necessarily need to be the same as the local warehouse name.
Click Create to create an empty remote repository.
The bulk of the hints here are the rest of our operations. Note Remember the above SSH link, preferably without HTTP;
Go back to this in Git bash:
Because the SSH link host requires password authentication, we need to establish the key in this machine and register it on the remote host, the following is the process of establishing SSH key:
Use the command to check whether the local user home directory is named. SSH key to save the folder and key file.
ls -al ~/. SSH
If there is no prompt you, generally you have not used git bash or SSH to establish the key does not have this folder, or folder does not have files.
After the key is established, use the following command:
Ssh-keygen " your email addr "
Note The email address is also unlimited and which must be the same.
I operate as follows:
Note in the input file name there is a direct carriage return, the default key file name is Id_rsa, the public key file is named Id_rsa.pub
Then enter the password and confirm it, the success will be returned fingerprint identification and random characters to draw, do not remember.
Then locate the public key file with the suffix. Pub under the user home directory. SSH folder and open it with a text editor and copy all of its contents.
When you're done copying back to GitHub,
In the upper right corner of the main interface, find the option to set that:
The logo is a gear;
Select SSH key after opening
Click Add SSH key to add the key name and key contents in the UI that appears:
then click Add. Note that adding a success will notify you by email (you refer to GitHub registered mailbox holder).
Then go back to git bash and enter the following command to detect if you can ssh to GitHub,
ssh -t [email protected]
There may be a warning, leave him, enter the password is when you set up the key password.
The instructions appear to successfully connect to GitHub.
We then submit the local repository to the remote repository as follows:
Before uploading, make a summary of the changes and write "log".
" .................. "
Add a text description to the ellipsis.
To establish a connection between the local warehouse and the remote repository:
git remote add origin [email protected]:wylhyz/learngit.git
Origin is a remote repository with local aliases that you can freely fetch, and git links are ssh connections that you write down when you set up a remote repository. This sentence is to establish a remote repository alias locally and link to the remote repository.
You can then upload the changes directly using the following command:
Git push-u Origin Master
It is good to enter the key password when password verification is required. (Of course there is no input method)
Now that you've uploaded the repository on GitHub, the upload is complete:
Even the description I wrote.
There will be so much for the time being, and other things to know to add.
Above.
Using Git and GitHub to build a remote repository under Windows