From owner-dev-commits-doc-all@freebsd.org Thu Jun 3 13:03:04 2021 Return-Path: Delivered-To: dev-commits-doc-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CFC5063906D for ; Thu, 3 Jun 2021 13:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FwmKN594jz3FbP; Thu, 3 Jun 2021 13:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 98A8F24BB; Thu, 3 Jun 2021 13:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 153D34Rx089989; Thu, 3 Jun 2021 13:03:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 153D34xb089988; Thu, 3 Jun 2021 13:03:04 GMT (envelope-from git) Date: Thu, 3 Jun 2021 13:03:04 GMT Message-Id: <202106031303.153D34xb089988@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Warner Losh Subject: git: cd2b40e5b8 - main - git: document how to merge a pull request from github. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd2b40e5b8d5f4ca05ab1ce43a736d406f051119 Auto-Submitted: auto-generated X-BeenThere: dev-commits-doc-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the doc repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2021 13:03:04 -0000 The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/doc/commit/?id=cd2b40e5b8d5f4ca05ab1ce43a736d406f051119 commit cd2b40e5b8d5f4ca05ab1ce43a736d406f051119 Author: Warner Losh AuthorDate: 2021-06-03 13:02:25 +0000 Commit: Warner Losh CommitDate: 2021-06-03 13:02:25 +0000 git: document how to merge a pull request from github. Reviewed by: ceri@, ygy@ Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D30589 --- .../en/articles/committers-guide/_index.adoc | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/documentation/content/en/articles/committers-guide/_index.adoc b/documentation/content/en/articles/committers-guide/_index.adoc index 82800ccfd7..f3c63a4943 100644 --- a/documentation/content/en/articles/committers-guide/_index.adoc +++ b/documentation/content/en/articles/committers-guide/_index.adoc @@ -2208,6 +2208,60 @@ To github.com:gvnn3/freebsd-src.git At this point your work is now in your branch on +GitHub+ and you can share the link with other collaborators. +=== Landing a github pull request +This section documents how to land a GitHub pull request that's submitted against the FreeBSD Git mirrors at GitHub. +While this is not an official way to submit patches at this time, sometimes good fixes come in this way and it is easiest just to bring them into a committer's tree and have them pushed into the FreeBSD's tree from there. +Similar steps can be used to pull branches from other repositories and land those. +When committing pull requests from others, one should take extra care to examine all the changes to ensure they are exactly as represented. + +Before beginning, make sure that the local Git repo is up to date and has the correct origins set <> +In addition, make sure to have the following origins: +[source,shell] +.... +% git remote -v +freebsd https://git.freebsd.org/src.git (fetch) +freebsd ssh://git@gitrepo.freebsd.org/src.git (push) +github https://github.com/freebsd/freebsd-src (fetch) +github https://github.com/freebsd/freebsd-src (fetch) +.... +Often pull requests are simple: requests that contain only a single commit. +In this case, a streamlined approach may be used, though the approach in the prior section will also work. +Here, a branch is created, the change is cherry picked, the commit message adjusted, and sanity-checked before being pushed. +The branch `staging` is used in this example but it can be any name. +This technique works for any number of commits in the pull request, especailly when the changes apply cleanly to the FreeBSD tree. +However, when there's multiple commits, especially when minor adjustments are needed, `git rebase -i` works better than `git cherry-pick`. +Briefly, these commands create a branch; cherry-picks the changes from the pull request; tests it; adjusts the commit messages; and fast forward merges it back to `main`. +The PR number is `$PR` below. +When adjusting the message, add `Pull Request: https://github.com/freebsd-src/pull/$PR`. +[source,shell] +.... +% git fetch github pull/$PR/head:staging +% git rebase -i main staging # to move the staging branch forward, adjust commit message here + +% git checkout main +% git pull --ff-only # to get the latest if time has passed +% git checkout main +% git merge --ff-only staging + +% git push freebsd +.... + +[.procedure] +==== +For complicated pull requests that have multiple commits with conflicts, follow the following outline. + +. checkout the pull request `git checkout github/pull/XXX` +. create a branch to rebase `git checkout -b staging` +. rebase the `staging` branch to the latest `main` with `git rebase -i main staging` +. resolve conflicts and do whatever testing is needed +. fast forward the `staging` branch into `main` as above +. final sanity check of changes to make sure all is well +. push to FreeBSD's Git repository. + +This will also work when bringing branches developed elsewhere into the local tree for committing. +==== +Once finished with the pull request, close it using GitHub's web interface. +If the changes are fetched with https, this last step is the only one requiring a GitHub account. [[vcs-history]] == Version Control History