Mac uses git to manage GitHub

Source: Internet
Author: User
Tags using git

工欲善其事, its prerequisite.

Install the latest version of Xcode in OS X Yosemite 10.10.3, and under terminal you can see that git is already installed.

~ mesut$ git--versiongit version 2.3.2 (Apple Git-55)

Previously registered and used GitHub, but it has been managed remotely under the window System.

Now start setting up Mac management GitHub, one thing you need to know is that the local git repository is encrypted with the GitHub server via SSH.

Execute at Terminal

Ozil:tmp mesut$ ssh-vopenssh_6.2p2, Osslshim 0.9.8r 8 Dec 2011usage:ssh [ -1246AACFGKKMNNQSTTVVXXYY] [-B bind_address] [- C Cipher_spec]           [-D [Bind_address:]port] [-e Escape_char] [-F configfile] [-i           PKCS11] [-i-identity_file]           [-l [Bind_address:]port:host:hostport]           [-l login_name] [-M mac_spec] [-O ctl_cmd] [-o option] [-P port] [-R] [           Bind_ Address:]port:host:hostport] [-S ctl_path]           [-W Host:port] [-W Local_tun[:remote_tun]]           [[email protected]] hostname [command]

Obviously the Mac already has SSH installed.


1: Create SSH Key


Enter the current user directory, and the wavy line represents the current directory. Determine if the. SSH is already installed, and avoid the default installation overwriting the previously installed. Obviously the current directory does not have this file

Execute Create SSH key

Ssh-keygen-t rsa-c "[Email protected]" (your github login name)

Then all enter, select the default directory, the default password can be

Generating public/private RSA key pair. Enter file in which to save the key (/users/mesut/.ssh/id_rsa):     Created directory '/users/mesut/.ssh '. Enter passphrase (empty for no passphrase): Enter same passphrase Again:your identification have been saved In/users/mesu T/.ssh/id_rsa. Your public key has been saved in/users/mesut/.ssh/id_rsa.pub.


It can then be found in the user's home directory..sshdirectory, inside thereid_rsaand theid_rsa.pubTwo files, these two are key pairs of SSH key

ozil:~ mesut$ CD. Sshozil:.ssh mesut$ lsid_rsaid_rsa.pub


2: Set SSH key on GitHub

Login to GitHub, "Settings", "SSH Keys", "Add ssh key"






title: You can fill in the name by the way

key: paste the id_rsa.pub contents of the file

Click on the Add key to complete the configuration

3: Test whether the local is connected to GitHub

Steve

Ozil:.ssh mesut$ ssh-t [email protected]the authenticity of host ' github.com (XXX) ' Can ' T be established. RSA key fingerprint is xxx. Is you sure want to continue connecting (yes/no)? Yes
The first link to GitHub, there will be a confirmation thatyou need to confirm that the fingerprint information for GitHub key is really from the GitHub server, enter yesyou can enter.

warning:permanently added ' github.com,xxx ' (RSA) to the list of known hosts. Hi tanchongshi! You've successfully authenticated, but GitHub does not provide shell access.

4: Update to GitHub with a locally created project using Git

Ozil:githubspace mesut$ mkdir hellogithubozil:githubspace mesut$ cd hellogithub/ozil:hellogithub mesut$ Ls-ah...ozil: Hellogithub mesut$ git initinitialized empty git repository in/users/mesut/documents/githubspace/hellogithub/.git/ Ozil:hellogithub mesut$ ls-ah....gitozil:hellogithub mesut$ touch newfileozil:hellogithub mesut$ Lsnewfileozil: Hellogithub mesut$ git add newfile ozil:hellogithub mesut$ git commit-m ' first commit ' [Master (root-commit) 2295d3e] Firs T commit committer: >v< <[email protected]>your name and email address were configured automatically base Don your username and hostname. Please check the that they is accurate. You can suppress this message by setting them explicitly.  Run thefollowing command and follow the instructions in your editor to edityour configuration file:git config--global --editafter doing this, your may fix the identity used for this commit with:git commit--amend--reset-author 1 file C Hanged, 0 insertions (+), 0 deletions (-) Create mode 100644 NewFile 

First initialize a git repository locally

Because the user name was not previously configured, the first commit will be prompted to automatically establish

Setup mode

$ git config--global user.name "Your name" $ git config--global user.email "[Email protected]"


To push a local repository to a remote server, you first need to build a project on GitHub


In Repository name, fill in the name of our project, description, the other default.

The project is then generated

Then associate the remote project with the local library

Ozil:hellogithub mesut$ git remote add origin [email protected]:tanchongshi/hellogithub.gitozil:hellogithub mesut$ git Push-u Origin masterwarning:permanently added the RSA host key for IP address ' XXX ' to the list of known hosts. Counting Objects:3, done. Writing objects:100% (3/3), 217 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (Delta 0) to [email protected]:tanchongshi/hellogithub.git * [New branch]      master, Mast Erbranch Master set up to track remote branch master from Origin.


Https://github.com/tanchongshi/hellogithub

So far so good~


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Mac uses git to manage 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.