Using GitHub also has a period of time, think of the first time with GitHub is also quite tortuous, from the configuration key to upload, but the feeling is quite troublesome, want to summarize how to configure the SSH key and how to upload the code to GitHub, where all operations are carried out under OS X system, I use the time is not very long, all if there is better usage or explanation error, please tell me, Thanks()
GitHub authentication Method
There are two ways to verify your identity when uploading to GitHub:
1. User name and password verification
2. SSH Key Verification
The above two ways can be verified, but personally, still prefer to use SSH secret key, as for why, I believe in the future use of the time you naturally understand the convenience of using SSH keys. So here's just a description of how to configure the SSH key
To configure the location of the SSH secret key
- After registering, log in to GitHub and select the Settings (config) option under identity in the top right corner, as
- SSH and GPG Keys
- Because I have already set up SSH, so here will show an SSH key, but it doesn't matter, the first setting will certainly be the following situation, title write GitHub account can:
Verify that the SSH key is present
Next we need to find our key, when it comes to finding key, he has a id_rsa
file called, how to find this file?
Verify that the SSH key already exists by using the command line in the terminal
ls -al ~/.ssh
If the terminal appears with the following line of code, it indicates that the SSH key has been generated
Runintolovemacbook-pro: ~ yuewen$ ls-al~/.Sshtotal +Drwxr-XR- x 6Yuewen Staff204 One - -: + .Drwxr-XR- x+ *Yuewen Staff1190 4 6 A: - ..-RW- R--R--@1Yuewen Staff6148 A 9 A: A .Ds_store-RW------- 1Yuewen Staff3326 1 6 -: ,Id_rsa-RW------- 1Yuewen Staff742 1 6 -: ,Id_rsa.Pub-RW- R--R-- 1Yuewen Staff2794 2 in -: theKnown_hosts
SSH key already exists
In this case, simply copy the key and paste it into the key in the configuration, and use the command line to complete the copy operation of the key.
pbcopy < ~/.ssh/id_rsa.pub
There is no SSH secret key
There is no SSH key and no need to worry, generate a line, the following operation is also done in the terminal
1. Create a new SSH key
ssh-keygen-t-b4096-C"[email protected]
2. Determine a file to save the secret key, the default is Id_rsa, confirm can
afileintothe key (/Users/you/.ssh/id_rsa): [Press enter]
3. Confirm the password and complete the creation of the secret key.
Enter passphrase (emptyfor no passphrase): [Type a passphrase]Enter same passphrase again: [Type passphrase again]
4. Build complete, verify SSH key is available
eval"$(ssh-agent -s)
5. Write the SSH key to the file
$ ssh-add ~/.ssh/id_rsa
6. Now the id_rsa.pub file already exists ssh, copy it out, the method above has OH.
File Upload
Upload method
- Xcode upload
- Terminal command line Upload
Create a project in GitHub
Click +New repository
and complete the comments on the project Create repository
to
At this point, there will be a key link, through this link to complete the local SSH key check, so that the upload,, here is naughty, use when the copy can be
Xcode upload
1. Once the code is complete, configure the remote and configure the location as follows:
2. Select Remotes
, there is one in the lower left corner +
, then Add Remote
3. The address at this time is the SSH link that created the project, and the copy Add Remote
is completed.
4. Remember before each submission Commit
, Xcode is Commit
also in Source Control
, meaning to save the changes to the local. The following can write notes, such as modified XX
5. In order to avoid conflict, in addition to the first upload, other times to remember Pull
, and then click Push
. The following box will pop up, verify the option SSH keys
6. See GitHub again, upload success!
Command line Upload
Drag the project file to the terminal
1. Add a remote
//在终端输入命令行add‘SSH的那个链接‘
2.Commit save it, "" Fill it in.
commit -m "第一次提交"
3.Push up and then
git push- uOrigin Master//If the code indicates push completionRunintolovemacbook-pro: Githubtest-terminal.Xcodeproj yuewen$ git push- uOrigin Mastercounting objects:9, done.Delta compression using up to 8Threads.Compressing objects: -%(7/7), done.Writing objects: -%(9/9),1.49KiB| 0 bytes/s, done.Total9(Delta4), reused0(Delta0) to[Email protected].Com:yrunintolove/githubtest.Git0610732.. 90508D7 Master -Masterbranch MasterSetUp toTrack Remote Branch master from Origin.Runintolovemacbook-pro: Githubtest-terminal.Xcodeproj yuewen$
4. Take a look at GitHub and upload success!
GitHub push appears the local repository is out of date
If this problem occurs, you can go to the previous blog to solve the GitHub push appears the local repository is an out of date resolution, wish smooth.
GitHub Settings & Code uploads