How do I upload a local project to GitHub using Git? (Mac Version)

Source: Internet
Author: User
Tags using git

Let's say you've created a project on GitHub, like this:

And you've done your own project code,

At the same time you have Git installed and let ' s start.

First of all, build a folder such as the text shows the applet folder, and then open your terminal, navigate to the folders,

Then enter the command: Git init

Then configure SSH, enter: ssh-keygen-t rsa-c "[Email protected]" (the mailbox is replaced by your login to GitHub's mailbox)

This place please note that it will generate SSH key under the path you choose, and if you click enter directly, SSH will be created under the default path. If you have multiple projects, have work, have your own play, then please configure a different path, or a path to change the file name, I use:/users/lijiayi/.ssh/id_test_rsa as a demonstration. After entering the path, click Enter.

This place is for you to enter the password, the direct return is not set the password. You can go directly to the carriage. Then you will be asked to repeat the password, and also directly enter.

When you appear, it means that SSH has been generated.

This execution command:pbcopy < ~/.ssh/id_test_rsa.pub   这个的作用是将你的 ssh 代码复制到剪贴板。

Now that we're back on the GitHub page, we need to configure the SSH you just generated to GitHub. Click on your avatar:

Then click Settings Settings:

Click Configure SSH:

Click Create New SSH Key

Directly crl+v the copy you have just copied in the Clipboard into the key input, the title you randomly up. Then click Add SSH Key.

Now, let's open the terminal and verify that SSH was added successfully, enter the command: ssh-t [email protected]

When the sentence appears, you get up and dance. If it is a sentence similar to the following:

 the authenticity of host "  git.net (116.211.167.152)   " can"  t be Established.  ECDSA key fingerprint is  sha256:fqgc9kn/eye1w8icdbgrqp+ kkgyofgbvr17bmjey0wc.are you sure your want to  continue  connecting (yes/no)?  yeswarning:permanently added   " git.oschina.net,116.211.167.152   "  (ECDSA) to the list of known hosts. Permission denied (publickey).   

Or permission denied, you execute the command again:ssh-add ~/.ssh/id_test_rsa

Re-enter SSH-T [email protected] If the prompt is successful, we will continue, if not successful, you will Google the error of the newspaper.

When you're successfully, let's set up your github login and login mailbox in git config to execute the following two commands:

git config--global user.name "Your name"

git config--global user.email "[email protected]"

Now we can upload the code!!

Pull your project code into this folder, execute the command, git status

At this point you will see all the changes and then execute git Add. (There's a point oh, this point means change all the changes)

Then execute the command git commit-m "first update"

Then execute the command: Git remote add github https://github.com/your user name/github project name. Git

Final execution command: git push-f GitHub (GitHub here is the remote branch you created)

Now go back to your GitHub page and then refresh the project page, wow color, what is this

Go dance.

Some of the issues you might encounter as well as reference sites:

*mac multiple git account configurations: HTTP://WWW.JIANSHU.COM/P/FBBF6EFB50BA

*cannot push to GitHub, keeps saying need merge:http://stackoverflow.com/questions/10298291/ Cannot-push-to-github-keeps-saying-need-merge

* Delete GitHub remote branch: https://my.oschina.net/tsingxu/blog/84601

Remember to recommend and follow me Oh ~

How do I upload a local project to GitHub using Git? (Mac Version)

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.