If you have a good project and want to share it with you, GitHub will be the right choice for you. How can you upload your project to GitHub? Next step, follow along.
Resources to prepare:
1. A Mac Machine
2. Install the GIT client (: http://code.google.com/p/git-osx-installer/downloads/list?can=3) and download it and install it directly.
3. One GitHub account (registered address: https://github.com/join?source=header-home)
4. An electronic dictionary (if it is a good English level of small partners, it is not necessary, because the registration process for all-English, and other operations are in English)
5. Your project
When you're ready, you can start.
One. Create your own SSH. SSH is the abbreviation of Secure shell, meaning the security shell protocol, the specific content please Baidu search "SSH". The steps to create are as follows:
1.1 After logging in to the GitHub website, locate the button shown and select "Settings"
1.2 Next you will see, select "SSH and GPG Keys"
1.3 Next you can create your SSH keys and find the button "new SSH keys" shown in
Here's the problem.
What do these two boxes fill?
Do not worry, the following code box will tell you what should be filled in, but here we may have to diverge for a while, tell us where the two boxes of the things come from? Do not hurry, very short, do not run God son Oh! But I'll remind you to get back on track.
Open Terminal
The black question is to be entered manually, "/**/" in the prompt language, tell you what is the use of it?
$ssh-keygen-t rsa-c [email protected]/* email*/generating public/private RSA key pair when you register for GitHub. Enter file in which to save the key (/USERS/.../.SSH/ID_RSA):/* Here the cursor will stop, wait for your input, do not enter, directly enter "Enter/return" */Created D Irectory '/users/.../.ssh '. Enter passphrase (empty for no passphrase):/* Here is to let you set your SSH password, do not lose, the default no password */enter same passphrase again:/* Re-enter the password to Verify */Your identification has been saved In/users/.../.ssh/id_rsa. Your public key has been saved in/users/.../.ssh/id_rsa.pub. The key fingerprint is:18:16:11:c9:01:6c:48:09:7f:27:c6:43:0d:7f:3f:84 [email protected] The key ' s ran Domart image is: +--[RSA 2048]----+ |. o.++=== | |. ooo.+. . | | .. * = E. | | o = + O | | . S O | | . | | | | | | | +-----------------+
Next please open the path shown above (open File Manager, commend+shift+g, paste the path into the carriage return), you can see two files "Id_rsa" and "id_rsa.pub", using a text editor to open the "id_rsa.pub" Copy all of the contents.
Okay, relax and get back on track! And go back to just the page, first in the "Title" in the text box, enter your registered mailbox, in the "Key" text box paste just copied things, click the "Add SSH Key" The words of the green button, you are done.
Two. After you have created your own SSH, create a profile for your project.
2.1 Do you remember the page where the GitHub site was just stuck? Yes, set SSH keys page, now, on this page find the button shown, click "New Repository"
2.2 You will see
2.3 The next step is to fill in the explanation of the information: Repository name----your project is a simple description of;description-> your project; The following radio determines whether the project is public or private, and sometimes everyone can see it, and who can choose when it's private. The following check box determines whether to write your project description to the "readme.md" file. Next click "Create Repository".
Three. Well, the work of uploading the project is nearing the end, hold on, and look down.
3.1 Open terminal, enter the following command
CD ~/.ssh
If the above steps are all right, you should go to that path at this point. The following will be a magical thing, in the terminal can complete the code upload work.
Before uploading, make sure the terminal is connected to GitHub and enter the following command to test
ssh-t [email protected]
The successful return of the connection should be
Hi "Your name"! You've successfully authenticated, but GitHub does not provide shell access.
3.2 To type the following command
Touch README.MD//Create a document for a record submission operation git init/initialize local repository git add readme.md//Add File git commit-m "first commit"//submit to local repository and comment git remo Te add origin [email protected]:youname/test.git//Connect to the remote repository and build a name: Origin alias Git push-u Origin master// Submit the contents of the local repository to the address that is origin, under the master branch
What did the above code do? In fact, it is only a text file submitted to the "master" branch, nothing special, it is worth noting that the inside of the "add", "commit" and "push" three operations, "add" can add more than one file in multiple lines of typing, you can also add all the files under the current directory "Add." Yes, "commit" is committed to the local repository, note that the local warehouse, this operation does not affect the remote code, "push" operation is to push the locally modified code to the remote branch.
3.3 Last step, upload your project to GitHub. Type the following command
Explain that the above switch to the path where your project is located, so you can use "Add." command to upload all of the item's pricing to GitHub.
3.4 Ben came here you should have successfully uploaded your project, but may also meet some problems
For example
to [email protected]:P Aulpaulbobo/forhealth.git! [Rejected] Master-to-Master (Non-fast-forward) error:failed to push some refs to ' [email protected]:xxx.git ' hint:updates were Rej ected because the tip of your current branch is behindhint:its remote counterpart. Integrate the remote changes (e.g.hint: ' git pull ... ') before pushing Again.hint:See the ' Note about Fast-forwards ' in ' git push--help ' for details.
It says upload some "refs" error, please pull before pushing, why is this? The reason is that the local code with the remote conflict caused, should first pull the remote code back to local and then upload.
Git pull--rebase git push--dry-run--verbose origin head:master git push Origin Head:master
This will solve the conflict problem. Of course, in the late development, if the conflict problem is more, you have to manually modify some of the conflicting files before you can upload. It is recommended to use the Sourcetree client (: https://www.sourcetreeapp.com/download/).
Well, after the project has been uploaded, you can discuss your project with the whole world!
Step-by-step tutorial on how to open your own project to GitHub, Mac machine sample