Upload Project to GitHub

Source: Internet
Author: User

Here is the main talk about how to use GitHub under the Mac, I just started to use, or a bit of Kung Fu, because the online information is miscellaneous, some are not too accurate. Therefore, the installation process of their own more detailed sharing, to facilitate the needs of people, save a bit of character.

First of all, you have to complete the following two jobs:

    1. Download Install git client http://code.google.com/p/git-osx-installer/downloads/list?can=3
    2. Sign up for a GitHub account https://github.com/-->pricing and Signup-->create a free accounts

To create an SSH:

Next open the terminal (do not know where the terminal, directly in the Spotlight search terminal):

CD ~/.SSH Check if it already exists

If it exists, it will not exist (in general) to have an existing SSH backup, or to build the new SSH into another directory

If it does not exist, SSH is generated directly from the default parameters:

First CD-/.ssh will appear as:

e-mail address fill in the email address of your registered GitHub.

Login to GitHub, select Account settings-->ssh Keys to add SSH

Title:[email protected] (own mailbox)

Key: Open the Id_rsa.pub file you generated, (go to the folder; The path is/users/your home folder/.ssh/id_rsa.pub, for example:/users/chendianming/.ssh/id_rsa.pub), Then copy the contents into the following:

Open the terminal, first test your account with GitHub does not have: ssh-t [email protected] If the following prompt, indicating that you are connected. (Because of the first step, so you don't have to do too much to connect to GitHub, and the next time you want to connect to GitHub remember to open the first step of the tool).

If the authenticity of host ' github.com (192.30.253.112) ' can ' t be established appears. Is you sure want to continue connecting (yes/no)? Please enter Yes

Cause: not associated with local warehouse on 1.github (few cases)

2.ssh not true (this is basically the case)

SSH Resolution:

1. Cat ~/.ssh/id_rsa.pub to see if SSH is your own (the following is your own mailbox description is your own), not to indicate that it is an SSH problem, or if it is a remote association problem

2. If it is an SSH problem, delete the same directory in the Git repository. SSH folder (hidden folder)

Determine deletion success: Cat ~/.ssh/id_rsa.pub

Appears cat:/c/users/user name/.ssh/id_rsa.pub:no such file or directory

3. Re-create SSH ssh-keygen-t rsa-c "[Email protected]"

If Hi domanc! appears You've successfully authenticated, but GitHub does not provide shell access. Description succeeded.

Then you can upload your code and build your own repository on GitHub. Create a New repository is as follows:

Repository name: Usually write your own project name to build.

Description: That's your description of the project.

Select public.

Add.gitignore Choose that language

ADD a license Select a protocol, see below this, also can self-degree Niang:

https://www.zhihu.com/question/27114031

When the above operation succeeds, it will go to:

Next, create a test project and then enter the command at the terminal:

1.cd/users/chendianming/desktop/test

2.git Init

3.git add-a

4.git commit-m "Init file"

5.git remote add origin [email protected]:d Omanc/test.git

6.git Push-u Origin Master

If an error occurs:

ERROR:SRC Refspec Master does not match any.
引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

error: insufficient permission for adding an object to repository database ./objects
服务端没有可写目录的权限

Error tip: Fatal:remote origin already exists.
WORKAROUND: $ git Remote RM origin
Error hint: error:failed to push som refs to ....
Workaround: Git pull Origin master//pull down and push up

The github repository you just created, error in the push code:

$ git push-u origin master
to [email protected]:* *****/demo.git
 ! [Rejected] master, Master (Non-fast-forward)
error:failed to push some refs to ' [email protected]:* *****/de Mo.git '
Hint:updates were rejected because the tip of your current branch is behind
Hint:its remote counterpart. M Erge the remote changes (e.g. ' git pull ')
Hint:before pushing again.
Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.

was searched online because remote repository and my local repository conflict resulted, and after I created the repository, Click on the Create Readme.md file button on GitHub's repository page to create a description document, but no pull to local. This creates a problem with version conflicts. There are several workarounds for

:

1. Methods for using forced push:

$ git push-u origin master-f

This can make remote modifications missing, which is generally undesirable, Especially when many people collaborate on development.

2.push before the remote repository modification pull down

$ Git pull Origin master

$ Git push-u Origin master

3. If you do not want to merge remote and local modifications, you can first create a new branch:

$ git branch [name]

then push

$ git push-u origin [name]

This error occurs:

! [Rejected] master, master (Non-fast-forward)

See this http://blog.csdn.net/chain2012/article/details/7476493 for details.

Upload Project to GitHub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.