GitHub is a managed platform for open source and private software projects, an open source codebase, and a version control system because Git is hosted only as a unique repository format, so it's called GitHub. There are a lot of tutorials for using GitHub under Windows, so there's no need to have a home page for more. This article focuses on how to use GitHub on Mac OS x systems. In fact, the use of GitHub on Mac OS x system tutorial Online also has, but most are too old, in addition to the system or user interface update, some of the content is very inaccurate, which often brings great trouble for beginners. The content discussed in this article is based on the latest version of the software, which is more useful for users of GitHub.
1. Register for GitHub
GitHub is first of all a Web site, in order to host your code on this site, you should first register as a user of the site. To do this, please login to GitHub's website (https://github.com/), then fill in the user name, email address and other information to complete the registration, as shown in.
There is not much to explain in the registration process, step by step and follow the instructions until the registration is complete, you can use this account to log in to your GitHub account! The login interface is as follows.
After successful login The interface is as follows (the visible red circle shows my login name). Because it is a new registered user, there are no managed software projects on GitHub. As shown, you can now read the GitHub User Guide (read the guide), which will show you how to use GitHub (which is, of course, what we're going to do next). Alternatively, you can start a new project directly (start a project).
2. Install or update git
In many tutorials, you will find that many developers operate and use GitHub through the command line interface. From a professional perspective, this is really the right way to turn on GitHub. In Mac OS x, the command line is also referred to as terminal. To manipulate GitHub by typing instructions in terminal, installing git correctly is a prerequisite.
Of course this article will focus on the method more than this (that is, the command line interface by typing instructions to manipulate GitHub) is easier, and later you will see that our approach is to use the client with a graphical user interface to operate on GitHub. However, it is still necessary to install Git. "If you don ' t already has Git installed, you must configure it before using GitHub desktop." This is also clearly stated in the user Manual of GitHub desktop. 。
Typically, GIT is already installed in Mac OS x. However, Git's version is not necessarily up-to-date. We still recommend that you install Git with the latest version. Let's check to see if Git is installed on your Mac computer. Open your terminal and enter Git after the prompt, as shown, if the GIT command can be recognized by the system, it means that git is already installed on your computer, and the system will list some of the ways Git is used (because the git command you're typing is incomplete).
Of course, some of the ways git is listed above may also be seen in the git--version command to see the version of the currently installed Git, let's practice it.
If you find that Git is not installed on your system, then you need to download and install the latest version of Git on the Git website (https://git-scm.com/downloads), as shown in.
Anyway, (even if you find that Git is already installed on your Mac OS x) we still recommend that you update your git in a timely fashion. Also shown in the Git download screen shown (where the bottom blue box is identified) if you have Git installed on your computer, you can automatically update git on your computer by typing the following instructions in terminal.
git clone https://github.com/git/git
For git and GitHub to work properly on your computer, this is a good step to complete.
3. Install GitHub Desktop
It's very handy to operate GitHub on Mac OS x via GitHub desktop, or a client on GitHub. To do this, log on to the GitHub desktop Web site (https://desktop.github.com/), and then select "Download for MacOS" as shown in.
The file you downloaded should be a zip archive, unzip it and get a program file called GitHub Desktop, and then drag the file to applications as shown in. This will show the GitHub desktop icon in Launchpad.
Use the user name you registered on the GitHub website below to configure GitHub Desktop. Start GitHub desktop from Launchpad, as shown, then select "GitHub desktop" → "Preferences" from the top left of the screen.
In the pop-up dialog box, select "Sign in" as shown. You will see two "Sing in", one is login to "github.com", the other is log in to "Enterprise". Note that "Enterprise" is a paid version, for ordinary individual users, please log in to "github.com".
Then enter your username and password in the login screen as shown, and press the "Sign in" button to complete the operation.
If you log in successfully (username and password are correct), the accounts interface shows you the user name you are currently logged into, as shown in. Also, in the Git tab, the user name and email address will be updated. Note that although the Git tab has been updated, we still suggest that you should click the "Save" button on the Git tab to save your account information in this step.
4. GitHub
To use GitHub to version your development project, you create "repositories" and then upload your project code, other files, to the appropriate repositories. After you log on to GitHub, click the icon in the upper-right corner and select "Your profile" from the drop-down menu, as shown in.
As shown, you will find that you have not created any repositories. Here we create repositories and upload project files to GitHub via GitHub desktop.
Create a new Repository locally, as shown in the "File" menu at the top of the screen and click "New Repository" in the GitHub desktop user interface without creating any Repository. New Repository ". Next, enter the name of repository in the dialog box that pops up (the system creates a folder of that name locally). Click the Create Repository button to complete the operation.
After a successful creation of a new Repository, as shown in the upper left corner you can see that "current Repository" is the Repository that was just created, because now this Repository is empty, so there is no file. It should also be noted that the My-first-git-proj icon is a computer shape, because the repository exists only on your computer and has not been uploaded to the GitHub website.
Remember to update the GitHub website synchronously. Click Publish Repository as shown, then fill in the necessary information in the popup dialog box and click Publish Repository to complete the operation.
After completing the above steps, the repository icon will change, which is no longer a computer-shaped icon. Also, if you log on to the GitHub site, as shown, you'll also find that my-first-git-proj is already in your repositories. Of course, if you click My-first-git-proj to enter the repository, you will also find that this is an empty project.
Let's add some files to the newly built repository folder (that is, the project update when you are developing the project). Then try to update the content on the GitHub website in sync. As shown, we put a Java program file in the My-first-git-proj folder (you can actually put any file in it).
Randomly you will find that the My-first-git-proj repository in the GitHub desktop interface has been updated with the latest added files. As shown in.
Now try to sync the project updates to the GitHub website. Now involves a concept branch, which is a setting for versioning. By default, all project content is located under Master Branch. Sometimes, however, you may want to retrieve the original version after you have modified the program file. To do this, you should create a new branch, and put the update in the new branch. If you want to retrieve the original changes before the file, as long as the original branch inside will be modified before the program files. Here's a demonstration of how to synchronize the update files inside the new branch.
5, Branch
First, look for "Branch" from the menu bar at the top of the screen and select "New Branch ..." from the drop-down menu, as shown in.
In the popup dialog box, edit the name of the new Branch, and click the "Create Branch" button to complete the operation as shown in.
Once the branch is created, edit summary and description (that is, something that describes the project file update), and then click the "Commit to ..." button (meaning to submit the latest update to the newly created branch), as in.
Then click on "Publish Branch" and GitHub desktop will sync the updated content to the GitHub website as shown in.
When you sign in to your GitHub site, you'll find that a new branch has been created in repository, and the newly updated project files have been uploaded to the GitHub site in sync. As shown in.
At this point, you have a basic understanding of how to use GitHub desktop in Mac OS X to work with GitHub.
Mac+github Usage Guide