GitHub on Fork + Pull Request Development mode _git

Source: Internet
Author: User
Tags diff rollback redmine using git git clone
4.1. Fork + Pull Mode

Participating in the project development in GitHub, the most commonly used and recommended preferred way is "Fork + Pull" mode. In "Fork + Pull" mode, project participants do not have to request submit permissions from the project creator, but rather to establish a derivation of the project (Fork) under their own managed space. If an open source project derives another project, it usually means the fragmentation of the project and the weakening of the development team, while the project derivation in GitHub is not, and on the contrary, the project derivation in GitHub is the embodiment of the project's strength. All derived projects will have links to the original project, the derived project has no independent defect tracking System (ISSUE), but must utilize the defect tracking system in the creator's own project. For submissions created in a derived project, it is easy to use the GitHub Pull request tool to send pull request to the maintainer of the original project. The following is an example of the Gotgit version library, which describes how to use the fork and pull request tools provided by GitHub to achieve work synergy. 4.1.1. Version Library derivation

The Gotgit version library [1] is used to maintain the website and errata of the Git authoritative guide book, and the Errata revisions shown below are reported by Wang Sheng [2] through a defect tracking platform other than GitHub [3]. In his report, he even told me how to modify it directly in the GNU diff format. The following is the user Gotgithub identity, access to the version library https://github.com/gotgit/gotgit/, add new errata. As shown in Figure 4-1, the Gotgit project has been our concern in previous examples but has not been fork. By clicking the Fork button to the right of the project name, you create a project derivation under the Gotgithub user's own managed space, and the derived Project version library appears in the version library list, as shown in Figure 4-2.

Access to the derived version library is almost the same as before the derivation, except that there is no defect tracking (ISSUE), and the original path before the project derivation is identified. As shown in Figure 4-3.

The Gotgithub user is now submitted in a locally derived version library. Clones the Gotgithub/gotgit version library.

$ git clone git@github.com:gotgithub/gotgit.git
$ cd Gotgit

In order to pay tribute to the discovery of the problem, and with the consent of Wang Sheng, in his capacity to submit.

$ git config user.name "Wang Sheng"
$ git config user.email wangsheng@ossxp.com

Edit the ERRATA.MKD file [4] To enter the text errors in the newly discovered book.

$ VI ERRATA.MKD

The changes to ERROR.MKD are as follows:

$ git diff
diff--git a/errata.mkd b/errata.mkd
index B0B68FB ... 29E40CF 100644
---a/errata.mkd
+++
b/errata.mkd @@ -14,5
 +14,6 @@ -14,5     66 | 11th line of the countdown                | Author (Submitted by)             |  Author (author)              | [Github#2] (HTTP://GITHUB.COM/GOTGIT/GOTGIT/ISSUES/2)    |
 |    144 | Line 1th                     | \ ' $ **git rev-parse  a^{tree}  a:**  | $ **git rev-parse a^{tree  }  a:**              | [#153] (http://redmine.ossxp.com/redmine/issues/153)  |
 |    218 | Line 8th                     | Under the condition, Gits identifies the merge conflict,           | Under the condition, Git identifies the merge conflict,                      | [#159] (http://redmine.ossxp.com/redmine/issues/159)  |
+|    369 | Line 21st                    | But the '-i ' parameter is only valid when executed on an item. | But the '-i ' parameter is valid only when executed on a project.     | [Github#3] (HTTP://GITHUB.COM/GOTGIT/GOTGIT/ISSUES/3)    |
 |    516 | Line 15th                | **oldtag= "Cat" * *             | **oldtag=\ ' cat\ ' * * |           [#151] (http://redmine.ossxp.com/redmine/issues/151)  |
 

Commit the changes. The number that appears in the submission statement is intended to be associated with the defect tracking system and will be described later in this section.

$ git add-u
$ git commit-m "Fixed #3: should be project, not item."

Push delivery to GitHub.

$ git push

Accessing the derived Items page on the GitHub, you will see the submissions created with user Whangsheng in Master branch [5]. As shown in Figure 4-4.

4.1.2. Pull Request

So how can you let the creator of the Gotgit original project know about this derivative project and the new submission? The tool provided by GitHub is "Pull Request". Notice the "Pull Request" button at the top right of figure 4-3. Click the button to enter the pull request creation interface. In the pop-up pull request creation interface, click "Commits" in the menu to view the included submissions. As shown in Figure 4-5.

Click "Files Changed" in the menu to view the included submissions. As shown in Figure 4-6.

Click "Preview Discussion" in the menu and fill in the title and content of Pull request to complete pull request creation. As shown in Figure 4-7.

When pull request is issued, the developer of the project Gotgit receives a notification message, as shown in Figure 4-8.

Click the URL link in the message to log in as the project Gotgit developer (such as ossxp-com) and see the view shown in Figure 4-9. Two users were seen participating in this pull request because the pull request creator and the author of the submission are different users. The form below Figure 4-9 can append comments to the pull request or close this pull request.

GitHub if you detect that the submissions contained in pull request can be merged directly, display the automatically merged prompts, and click the Auto Merge button in the message in Figure 4-9 to display the Automatic Merge dialog box for Figure 4-10.

Click the "Confirm Merge" button to complete the automatic merging of the submissions contained in pull request. After the automatic merge completes, the Pull request page will appear as a comment in the form of a related prompt, and automatically close the Pull request. As shown in Figure 4-11. 4.1.3. Manual Merging

Pull the automatic merge provided by the request is displayed in the submission log. Checking out a version library as a user ossxp-com will see that the user Wangsheng's submission has been merged into the version library.

$ git clone git@github.com:gotgit/gotgit.git
$ cd gotgit
$ git log--graph-3
*   Commit 6c1f1ee152629fd2f8d00ebe92c27a32d068d756
|\  merge:00c6c4b 7ecdfe7
| | Author:opensourcexpress <worldhello.net@gmail.com>
| | Date:   Tue Aug 01:23:47 2011-0700
|     | | Merge Pull request #4 from Gotgithub/master
|     | |  Find a typo on the book
| | |
* COMMIT 7ecdfe7451412cfb2e65bb47c12cf2162e21c841
|/  Author:wang Sheng <wangsheng@ossxp.com>
|   Date:   Tue Aug 10:17:53 +0800
|
|       Fixed #3: Should be project, not item.
|
* Commit 00c6c4bfab9824bd967440902ce87440f9e87852
| Author:jiang Xin <worldhello.net@gmail.com>
| Date:   Wed Aug 3 11:50:31 +0800
|
|     Change font color for stronger text from red to brown.

You can see that GitHub's automatic merge produces a merge commit, similar to the execution of the git merge--no-ff command. That is, even if the user Wangsheng commit is a "fast forward commit" (based on the latest submission from the Gotgit/gotgit version Library), a merge submission is also generated. Some people may not like this non-standard combination of –no-ff parameters because the merge produces an unwanted commit, which can add to the burden of code review. It is also easy to cancel the automatic merging of GitHub because Git is omnipotent:

$ git reset--hard head^  # Rollback A commit, that is, rollback to the currently submitted first parent submit
$ git rev-parse head      # Check for correct fallback
00c6c4bfab9824bd967440902ce87440f9e87852
$ git push-f             # Force push fallback Master Branch

Here's a demonstration of how to manually merge when someone else's pull request is received. In fact, in many cases, the Pull request contains submissions that are likely to result in a merge conflict, in which case GitHub no longer and cannot provide automatic merging, and must be manually merged. Add the derived version library of the pull request Publisher as a new source. For example, to receive a pull Request from a gotgithub user, you may wish to add a new source with Gotgithub name.

$ git remote add Gotgithub https://github.com/gotgithub/gotgit.git

At this point, there are two sources in the version library, a origin that is automatically created at the time of cloning, and the other is the newly added Gotgithub.

$ git remote-v
gotgithub       https://github.com/gotgithub/gotgit.git (fetch)
Gotgithub       https:// Github.com/gotgithub/gotgit.git (push)
origin  Git@github.com:gotgit/gotgit.git (fetch)
origin  Git@github.com:gotgit/gotgit.git (push)

Gets the branch and commit of the remote version library Gotgithub.

$ git fetch gotgithub from
https://github.com/gotgithub/gotgit
 * [New branch]      gh-pages   -> Gotgithub/gh-pages
 * [New branch]      master     -> Gotgithub/master
 

Now, in addition to the local branch master, there are several remote branches, as follows:

$ git branch-a
* Master
 remotes/gotgithub/gh-pages
 remotes/gotgithub/master
 remotes/origin/head -> origin/master
 remotes/origin/gh-pages
 remotes/origin/master

Merges the remote Branch Remotes/gotgithub/master (abbreviated as Gotgithub/master) into the current branch.

$ git merge gotgithub/master
updating 00c6c4b. 7ecdfe7
Fast-forward
ERRATA.MKD |    1 +
1 files changed, 1 insertions (+), 0 deletions (-)

Review the submission instructions to see that the merge did not produce unnecessary merge submissions.

$ git log--graph-2
* Commit 7ecdfe7451412cfb2e65bb47c12cf2162e21c841
| Author:wang Sheng <wangsheng@ossxp.com>
| Date:   Tue Aug 10:17:53 +0800
|
|     Fixed #3: Should be project, not item.
|
* Commit 00c6c4bfab9824bd967440902ce87440f9e87852
| Author:jiang Xin <worldhello.net@gmail.com>
| Date:   Wed Aug 3 11:50:31 +0800
|
|     Change font color for stronger text from red to brown.

Pushes the merge into the GitHub version library.

$ git push
4.1.4. Online editing

GitHub provides online editing so that you can modify files in a version library without cloning a version library, without using git, or even on your ipad or even the iphone. Log in as a Gotgithub account github, access the files in the repository gotgithub/gotgit that were derived from earlier, such as file Errata.md[6], and see one of the "Edit this file" buttons, as shown in Figure 4-12.

Click the "edit this file" button in Figure 4-12 to start editing the file online errata.md, and the editor also supports syntax highlights, as shown in Figure 4-13. 4.1.5. Simplified Fork + Pull Request

So far, we have learned about GitHub's three weapons: Fork, Pull request and online editing. For the most commonly used "Fork + Pull Request" operation, GitHub also provides a quick mode. That is, GitHub for files in other people's version libraries that do not have permission to change, provides a button similar to online editing, named "Fork and edit this file" button, automatically complete version library derivation and online editing, the three weapons will be Shi. Access to a file in another version library (not yet derived from your own space), such as access to the following address: Http://git.io/hello-world-makefile[7]. Displays the Src/makefile file in the others (ossxp-com) version library Hello-world, as shown in Figure 4-14.

Click the "Fork and edit this file" button in Figure 4-14 to automatically create a derived version library in your own hosting space and start editing the file Src/makefile online, as shown in Figure 4-15.

After the file has been modified, click the "Propose File Change" button to submit the change action to the derived version library and immediately open a new pull Request. As shown in Figure 4-16.

Click the "Send Pull Request" button to complete the creation of Pull request. If you look at Figure 4-16 carefully, you will find that the modifications contained in the pull request occur in the Patch-1 branch in the Gotgithub/hello-world derived version library, not the usual master branch. The original repository Ossxp-com/hello-world developers will receive an email notifying you of the new pull Request, as follows (first four behavior letterhead):

From:gotgithub <reply+i-... @reply .github.com>
date:2011/12/17
Subject: [Hello-world] Bugfix:build Target when Version.h changed.  (#1)
To:jiang Xin <worldhello.net@gmail.com>


Without this fix, when version changed only version.h update, Target RE Build needs a second ' make '.

You can merge this Pull Request by running:

 git Pull https://github.com/gotgithub/hello-world patch-1

Or You can V Iew, comment on it, or merge it online at:

 https://github.com/ossxp-com/hello-world/pull/1

--Commit Summary--
  * bugfix:build target when Version.h changed.

--File Changes--

M Src/makefile (3)-

-Patch Links--

 https://github.com/ossxp-com/hello-world/pull/ 1.patch
 https://github.com/ossxp-com/hello-world/pull/1.diff

---
Reply to this email directly or view It on GitHub:
HTTPS://GITHUB.COM/OSSXP-COM/HELLO-WORLD/PULL/1

The administrator of the version library Ossxp-com/hello-world can complete the auditing and merging of the Pull Request through the graphical interface provided by GitHub, or at the command line. As described in the message, use the command line as follows:

$ git pull Https://github.com/gotgithub/hello-world patch-1

[1] https://github.com/gotgit/gotgit/[2] https://github.com/wangsheng/[3] Http://redmine.ossxp.com/redmine/issues /161[4] Version Gallery Gotgit/gotgit has renamed the Errata file to errata.md. [5] The original master branch of the repository Gotgit/gotgit has been transferred to the Gh-pages branch, completing the compilation and deployment of the Web page through the GitHub Web site deployment mechanism provided. [6] The version library gotgit/gotgit has been refactored. The file errata.md file in the branch gh-pages from the ERRATA.MKD file from the original master branch, address: https://github.com/gotgithub/gotgit/blob/gh-pages/ Errata.md. [7] is the address https://github.com/ossxp-com/hello-world/blob/master/src/Makefile.

Turn from: http://www.worldhello.net/gotgithub/04-work-with-others/010-fork-and-pull.html

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.