Use GitHub under Mac

Source: Internet
Author: User
Tags git client using git version control system

Bring GitHub to believe that we are not unfamiliar, here will not repeat it. As an open source code base and version control system, the use of good is really very beneficial, besides the snobbish point, you find a job to the interviewer said you often maintain your own technical blog and GitHub, I believe you give him a lot better impression.

How to use GitHub under Windows, a lot of good people have already given a very detailed solution, you just ask the mother, she will help you solve, here for Windows under the use I will not repeat. 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.

工欲善其事 must first be a sharp weapon, first 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 SSH is already present

If it exists, first make an existing SSH backup, or build the new SSH into a different directory

If it does not exist, SSH is generated directly from the default parameters:
 $ssh-keygen-t rsa-c [email protected] (email when registering for GitHub) generating public/private RSA key pair.  Enter File           in which to save the key (/users/twer/.ssh/  id_rsa):         Created directory '/users/twer/.ssh '. Enter passphrase (empty for no passphrase): Enter same passphrase again:your identification have been save        D In/users/twer/.ssh/id_rsa.        Your public key has been saved in/users/twer/.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 |           |     .        |                 |        |                 |        |                 |       | +-----------------+

If you want to modify the SSH build directory, enter the path you want to generate in the bold location, and select default to generate the ~/.ssh

add SSH (shown) to GitHub: Login to GitHub, select Account settings-->ssh Keys to add SSH title:[email protected] Key: Open the Id_rsa.pub file you generated and copy the contents Here we are. Open the terminal, first test your account with GitHub not connected to: ssh-t [Email protected] If you see a hint like this, you're 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).
Hi miraclehe! You've successfully authenticated, but GitHub does not provide shell access.

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.
    • Click "Create Repository" to appear as:

Follow the steps above (remember to switch the directory to the project directory you want to upload when you enter it in the terminal). Simple analysis of the above steps:

Touch README.MD//Create a document for a record submission operation git init//Initialize local repository git add readme.md//Add git commit-m "first commit"//submit to Repository and write some notes git rem OTE 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

Issues to be aware of, when you do the following:

Key: Open the Id_rsa.pub file you generated and copy the contents to this

The id_rsa.pub file here is in the. SSH directory, and there may be a small partner who will find that their Mac does not see. ssh directory, am I kidding everyone? Of course not, how could I possibly do such a loser thing? did not see the. ssh directory, because the MAC has hidden the directory, if you do not believe, you can do the following to show the hidden files.

command to display Mac hidden files: Defaults write Com.apple.finder appleshowallfiles Yes hide mac hidden files command: Defaults write Com.apple.finder Appleshowallfiles No after you click the ENTER key to exit the terminal and restart the finder.

In fact, although you may not see the. SSH directory, you can still see the. SSH directory through the terminal commands, as follows:

With cat id_rsa.pub look inside is a bunch of foggy things, do not need to understand, copy to "key" on the line.

I believe I have been speaking more clearly, there are not clear little friends can leave a message.

analysis and resolution of difficult problems:

If you enter Git remote add origin [email protected]:d Jqiang (GitHub account name)/gitdemo (project name). Git

Tip error Message: Fatal:remote origin already exists.

The solution is as follows:

1. First enter GIT remote RM origin

2, then enter the GIT remote add Origin [email protected]:d jqiang/gitdemo.git will not error!

3. If you enter GIT remote RM origin or an error, error:could not remove config section ' Remote.origin '. We need to modify the contents of the Gitconfig file

4. Find your GitHub installation path, mine is C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\ etc

5, find a file named Gitconfig, open it to the inside of the [remote "origin"]那一行 delete it!

If you enter $ ssh-t [email protected]
Error message: Permission denied (PublicKey). Because the newly generated key cannot join SSH, it will cause the connection to not be on GitHub.

The solution is as follows:

1, first enter $ ssh-agent, and then enter $ Ssh-add ~/.ssh/id_key, so you can.

2, if still do not, enter Ssh-add ~/.ssh/id_key command after the error could not open a connection to your authentication agent. The workaround is key with the Git GUI SSH tool Generated, so that when the key is stored directly in SSH, do not need to ssh-add command to join, and other user,token and other configurations are done with the command line.

3, it is best to check if you copy the contents of the Id_rsa.pub file there is no extra space or blank lines, some editors will help you add these.

If you enter a GIT push origin master

Tip error message: error:failed to push som refs to ....

The solution is as follows:

1. First enter the GIT pull Origin master//start the remote server github file down

2. Then enter $ GIT push origin master

3. If an error occurs FATAL:COULDN ' t find remote ref Master or fatal: ' Origin ' does not appear to be a git repository and fatal:could not Read from remote repository.

4. You need to re-enter Git remote add origin[email protected]:d jqiang/gitdemo.git

The process of using Git to create a project locally

    $ makdir ~/hello-world    //Create a project Hello-world $    CD ~/hello-world       //Open this project    $ git init             /Initialize     $ Touch Readme    $ git Add readme        //Update Readme file    $ git commit-m ' first commit '     //Submit update and note the message "First commit" c13/>$ git remote add origin [email protected]:d efnngj/hello-world.git     //Connect remote GitHub project      $ Git push-u origin mast ER     //update the local project to the GitHub project

Delete all the. svn files under the folder find. -name ". SVN" | Xargs rm-rf//Delete all the. git files under the folder find. -name ". Git" | Xargs RM-RF

Use GitHub under Mac

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.