A simple guide to fork on Github and Git

Source: Internet
Author: User
Tags git commands

A simple guide to fork on Github and Git

In my experience, one of the most troublesome things I encountered when I first came into contact with Git and GitHub was to try to solve the following problem: What can I do on Git and GitHub?

Git tutorials often do not solve this problem, because they focus on teaching you Git commands and concepts, and do not think you will use GitHub. The GitHub help tutorials make up for this defect to some extent, but each article has a narrow focus and does not provide a conceptual overview of the "Git vs GitHub" issue.

If you are a beginner in Git and GitHub, I suggest you first understand what fork is. Why?

  1. Fork is the most common way to get started with GitHub.
  2. Fork only needs a small number of Git commands, but it does a lot of work.
  3. Fork provides the most basic understanding of Git and GitHub, which will benefit your future work.

This Guide uses two simple charts to teach you the two main work flows of fork. I do not intend to involve any code, but in the conclusion, I will give you the link of the code you need to use.

Fork and update a repository

Now there is a scenario where a programmer named Joe writes a game program and you may want to improve it. And Joe put his code on the GitHub repository. The following is what you want to do:

Fork and updates the chart demo of the GitHub Repository

  1. Fork his Repository: This is a GitHub operation. This operation will copy Joe's Repository (including file, submission history, issues, and other things ). The copied repository is under your GitHub account. Currently, your local computer has no operation on this warehouse.

  2. Clone your Repository: This is a Git operation. This operation allows you to send the "please send me a copy of my repository copy file" command to GitHub. Now the repository is stored on your local computer.

  3. Update some files: Now, you can update files in the repository in any program or environment.

  4. Submit your changes: This is a Git operation. Use this operation to send the "record my changes" command to GitHub. This operation is only completed on your local computer.

  5. Push your changes to your GitHub Repository: This is a Git operation. This operation allows you to send "this is my modification" to GitHub. The Push operation will not be completed automatically, so GitHub will not know your submission until you perform the push operation.

  6. Send a pull request to Joe: If you think Joe will accept your modification, you can send a pull request to him. This is a GitHub operation. This operation can help you communicate with Joe about your modifications and ask Joe if he is willing to accept your "pull request". Of course, it is up to him to accept the request.

If Joe accepts your pull request, he will pull those modifications to his own repository. Victory!

Synchronize a fork

Joe and other contributors have made some modifications to this project, and you will make some modifications based on their modifications. Before you start, you 'd better "Synchronize your fork" to make sure it works in the latest copy version. The following is what you want to do:

Synchronize GitHub fork charts

  1. Remove the changed files from Joe's Repository: This is a Git operation that allows you to obtain the latest files from Joe's repository.

  2. Merge these modifications to your own repository: This is a Git operation that uses this command to update those modifications to your local computer (those modifications are temporarily stored in a "branch ). Remember: Steps 1 and 2 are often used together as a command. The combined Git command is called "pull ".

  3. Push those changes to your GitHub repository (optional): Remember that your local computer will not automatically update your GitHub repository. Therefore, the only way to update the GitHub repository is to push those changes. You can execute push immediately after Step 2 is complete, or wait until you make some modifications and have submitted them locally before performing the push operation.

Compare the difference between fork and synchronization workflow: When you first fork a warehouse, the flow of information is from Joe's warehouse to your warehouse, and then to your local computer. However, after the initial process, the information flows from Joe's warehouse to your local computer, and then to your warehouse.

Conclusion

I hope this is a useful overview of fork on GitHub and Git. Now that you have understood those concepts, you will be more likely to execute your code in practice. GitHub's fork and synchronization articles will give you most of the code you need.

If you are a beginner of Git and you like this learning method very much, I strongly recommend the first two chapters of Pro Git, which can be viewed online for free.

If you like video learning, I have created an 11-part video series (36 minutes in total) to introduce Git and GitHub to beginners.

GitHub tutorials

How to create an organization on GitHub

Usage in GitHub Linux

How to build a GitHub development environment using Eclipse in Windows

This article permanently updates the link address:

Related Article

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.