How to configure/use GitHub on a Mac

Source: Internet
Author: User
Tags rollback ssh version control system ruby on rails

Let's start with a brief introduction to Git and GitHub, and the following text comes from Wikipedia.


Git is a version control tool for Linux kernel development. Unlike the commonly used version control tools such as Cvs,subversion, it uses a distributed version of the library, without server-side software support, so that the release and exchange of source code is extremely convenient. Git is fast, which is naturally important for large projects such as Linux kernel. The best of Git is its combined tracking (merge tracing) capabilities.


GitHub is an internet-based access service for projects that use the GIT version control system. It was written by GitHub Corporation (formerly known as the developer of Logical Awesome) Chris Wanstrath, PJ Hyett, and Tom Preston-werner using Ruby on Rails. GitHub also provides a business account and a free account for open source projects. According to a 2009 GIT user survey, GitHub is the most popular git access site.

It provides network diagrams like Feeds,followers and how developers work on versions of their version libraries.


Using GitHub can help us build control in project development and, even better, it can be used for free.


The following processes are summarized in the Web and in practice:

1. Download, install git, register GitHub: from Google code can be obtained from the Mac OS DMG installation file download address: http://git-osx-installer.googlecode.com/files/ Git-1.7.12-intel-universal-snow-leopard.dmg
Installation There is nothing to say, open the. dmg file, and then run the. pkg file, and then install it step by step. Git will be installed in the/usr/local/git/bin directory. Registration GitHub is also very simple, choose a free open source account type, step-by-step process can be.

2. Configure Git to enter in the terminal. SSH directory, if there are files in the directory, back up a copy and then obtain the key:

$ cd ~/.ssh
$ ls//If the directory already has files, set up a backup folder, back up the original files in

$ ssh-keygen-t rsa-c "Your mailbox @xxx.com"//

Then in the directory there will be a id_rsa.pub file, the file is just generated the key, with vim and other editors to open and copy content.
After entering the GitHub in the upper-right corner of account Setting, ssh keys->add ssh key and paste the key content just copied in the key bar.
When finished, return to the terminal and run:
$ ssh-t git@github.com

The display that appears later is filled with Yes and appears:

hixxx! You have ' ve successfully authenticated, but GitHub does not provide shell access.

That is, the connection succeeds.


If the connection fails, it is possible that the default 22 port is blocked and you can create a new file named config (without a suffix name) in the. SSH directory as follows:

Host github.com
User XXX@XXX.com
Port 443
Hostname ssh.github.com

To set user information after


$ git config--global user.name "XXXX"//own random name
$ git config--global user.email "XXX@XXX.com"
At this point, the GitHub configuration is complete.

3. The use of terminal and GitHub graphical interface GitHub The use of graphical interface one. Establish github repository and modify the submission code access to github.com and login, in the lower right corner of the page with your current repository information, click New Repository to create a new

In the next page, fill in the name and description of repository, create a Readme file (so that you can directly perform the clone operation) after the creation is complete, the upper left corner clone in Mac, you will appear in your native GitHub the clone option, name and address, Performs a clone operation, and a clone folder appears under the locally selected address.
Edit the Readme file locally, save will see GitHub has detected changes in the occurrence, then we can perform a commit operation, Commit&sync will be submitted to the online changes.

Refresh the page of the GitHub site to see that the changes have been submitted.


Two. Code rollback

In the process of writing code, it is common to encounter incorrect modifications that cause code corruption, with GitHub versioning, which can be restored by code rollback to the original code.

In the GitHub graphical interface of the history interface we can see all the changes we have made to submit, code rollback and other operations, point to open a submit operation



As you can see, there are two operations, Revert commit and Roll back to this commit, in which the Roll-to-this commit is to rollback the local code to the state after this submission, Revert commits to the Change all rollback, but if there is a submission after this submission there will be a conflict, said the latter.

Note that the above modifications are for local code, as long as there is no commit to the line code is not affected.




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.