How to use GitHub Desktop (MAC)

Source: Internet
Author: User

Directory

    • Download code from the repository locally (Clone Github Project to local Repository)
    • Locally updated web-side changes (pull)
    • Submit a new Code version locally to the repository (push local changes to remote repository)
    • Create a new branch (creating new branch)
    • Request to merge your own code (pull request)

GitHub is a popular code-management site and the world's largest gay dating site (funny). GitHub Web page you can freely host their own projects, you can fork other people's projects to play, very convenient, today I would like to introduce the GitHub desktop program, for the common needs of those related to the use of methods, here to Mac version for example, win on the basic similar.

And the process of learning the GitHub desktop version, in fact, is also a deep understanding of the various aspects of GIT technology, so git small white can also use GitHub desktop version to get started Git yo!

Next, I'll start with a more basic concept in GitHub, including Clone,branch,push,pull, to introduce how GitHub desktop is used.

Download code from the repository locally (Clone Github Project to local Repository)

First, when you don't want to open the GitHub site every time you edit your project files, you can choose to drop them down to the local disk. From then on, any changes you make to the project files locally will be recorded and can be easily synced to the GitHub site repository via the GitHub desktop program.

    1. Let's say we have a project called Tech-learning-notes on GitHub.

    1. Next, open the GitHub desktop version, click on the "+" button in the top left corner and select clone, and you'll see a list of items you've stored on GitHub (not yet down to local). Select the Tech-learning-notes project, select Clone Repository, and then select Local path to hold the project folder.

    1. Wait a moment, when clone is complete, you can see your project folder under the corresponding path you chose before.

Of course, you can move the folder location as you like, because the GitHub desktop program has locked the folder itself, not because you moved the folder location is not the same as the location of the previously saved lost Association. The "lock" is actually implemented through the ". Git" folder under the project folder, so don't move this folder easily!

Then you can happily edit your project locally at your own discretion.

Locally updated web-side changes (pull)

Once, your project partner submitted a new file on the page called "Friend's Change", so you are interested in synchronizing the new file to the local, very simple: click "Repository"-"pull", then, You can see the new files submitted by the collaborators in the local repository.

Submit a new Code version locally to the repository (push local changes to remote repository)

The problem is, we have made some new changes to our project locally, such as changing the source code of some files, adding and deleting some files, how do we synchronize these changes to the GitHub repository?

1. When you have made any changes to the files under the Local project folder, open the GitHub desktop program and you will find that your project page has become:

All the new entries that appear here are changes you have made to the project file, including modifying the code, adding or deleting files, and you can select to submit those changes to the repository by ticking the current check box.

2. After selecting the changes, fill in the comment box below to complete the changes to facilitate subsequent backtracking. (It is not possible to submit changes without filling in the title of the Change note.) )

After 3.commit, you will find a new ring on your project history node, representing your last commit record.

4. However, after committing only to save your changes and submit to the local code base, if you want the remote warehouse/github page to become the same as the local warehouse state, but also need to click "Repository"-"Push" to represent the new commit local changes Advance to the remote repository . In addition, you can click "Repository"-"Sync", you can complete the same effect, but sync synchronization as the name implies, also includes the remote repository changes to local actions, in other words, sync can be seen as a combination of push and pull operations.

5. After the sync is complete, the small ring becomes a point, which means the synchronization is completed, and then open GitHub's website, into the project, you will find the changes are synchronized (a new test folder).

Create a new branch (creating new branch)

Another important concept in the GitHub project is branching (Branch).

Suppose that one day you find that your project may be done with the structure of a common Java project and with the structure of a Java EE project, but you are not sure which is the best, so you and your friends discuss a person to make a version. However, you do the same project, but the architecture is different, then you can open two branches (Branch), each of which represents an architectural approach.

Or, if you are translating a Chinese book with a friend, you are responsible for translating it into English, and your friend is responsible for translating it into French, you can also operate on two branches, each of which belongs to the translation project of this book.

In short, all branches belong to one project, but each branch can be independent of each other, without interfering with each other, and any two branches can be merged when necessary.

In GitHub desktop, we first select the item to create the new branch, then click "File"-"New Branch" (for example), enter the name of the new branch, and select the template for the branch clone, that is, the new branch is copied with the current branch as the template.

Then, in "Repository"-"show branches" you can see the existing two branches, a default "Master", a new name of your own "new-demo-branch", and the branch after the small tick represents the branch you are now operating.

Next, the operations we perform under the current branch, whether adding or deleting files, are files for the current branch and do not have any effect on other branches.

However, the new branch you have created is not currently visible on the GitHub page because it is not yet public (publish), so you will see that there is a "publish" button on the right side of the progress bar of the new branch, and when you click on it, the new branch will appear on the page.

Request to merge your own code (pull request)

When you write a very good version of the code and feel that it is a great improvement on the current project, you want to be able to directly incorporate your code into the project, then you can initiate a pull request.

Write the reason for the pull request, then send it out, and then you can see the drop request under the project on the GitHub page.

On this side of the Web page, the project owner can discuss and review the pull request, and if you approve it, you can select "Merge Pull Request", which indicates the changes allowed to merge pull request submissions.

One of the important reasons why you should pull instead of just commit is: In general, a lot of people are fork in the project, and then make their own improvements, but you do not change the power of other people's projects, or chaos, you just can change your fork from other side of the project. But you feel that your improvements are great, you want to contribute your code and become one of the contributor of the original project, so you need to start a pull request and ask the owner of the original project to merge your code into the original project.

In addition, the content of the pull request can be easily discussed by everyone responsible for the project, and the joint decision should not incorporate these new changes into the project, thus preventing a contributor from being able to submit unreasonable changes due to incomplete consideration and thus damage the project.

How to use GitHub Desktop (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.