Guide: How to Fork on Github and Git
GuideIn 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? 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.
In my experience, one of the most troublesome things when I first came into contact with Git and GitHub is to try to solve the following problems: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?
- Fork is the most common way to get started with GitHub.
- Fork only needs a small number of Git commands, but it does a lot of work.
- 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 repositoryNow 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
- 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.
- 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.
- Update some files: Now, you can update files in the repository in any program or environment.
- 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.
- 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.
- 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 forkJoe 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
- 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.
- 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 ".
- 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.
ConclusionI 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.
Address: http://www.linuxprobe.com/fork-github-git.html