From nobody Wed Jun 25 15:32:06 2025 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bS5Qt409Fz609sm for ; Wed, 25 Jun 2025 15:32:06 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bS5Qt2DWSz413Y; Wed, 25 Jun 2025 15:32:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750865526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nAB6K4wH4CyoUAUEkAhC3VnMUt3JJxx/AQbPx4w0Q/4=; b=Zx+vVfR8aOKD50soGZQ62lbaezW14smrne6+X/vi1Vu4yXU4EESEM7Pit/krDJMRaF0xYM y3WNnXNtf022bK6oNkJknNLWQz2/ddBbqPV8Ku/qXbXdQ85lI4Rh6zPV9A3CWhGe7kS+Yo eg71SAUAPCAqtFxzbdEtb9mp7xXtpP/+aMN01NtX/Cq5vUxEL+2Lq23i6+jUTR4/d0ZHvg tp4Yvf7LqSVu6pjMrEYErdfcU6MDlS0X4Dx9rNMoOXes0WoeRBvgx8ZYsA5KVsv5Np0WF/ DnQfbr/exgNO5pwI2iW3uhXjaJYM0CK5MFjQKeRdyjhRcKHZRsKrsHm0PkhxOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1750865526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nAB6K4wH4CyoUAUEkAhC3VnMUt3JJxx/AQbPx4w0Q/4=; b=T1CzBUF/aIUB9je/92MCrkLF1RhIZ5VqYDh6y5I7qqRmf2dVyGTEa+6o0e9CZuapdqGKec b/NRsOhTzBInxieWljekR3Ng5YKxtQatvBb1p/R9AXtPBxfgK4WpUavOXdzB+E92I9OV/y q+IYXD8Y+fgvgyOfyutlctj6Sr/D/Sy43IYO21pA09LCx6Irtqc2enwsTwM0gfVHx1z7Rv UwtcqbV7oEYgQ4lUQWIduoKnl+jMaEmhwN5ELEH3HIl39sNjVvfhZlysGNv7i4nSxhLNb/ aDUYUK6oYLEoasS8WSAPNgAw1uO4CRHUxBkRa5svQQrQtynR+uTelBRp8eilxw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1750865526; a=rsa-sha256; cv=none; b=uzMAUUnIanHiLX2sQh+3UW6ik6oLB5Zms4bikBcJ5EoM1G9E2R8B7NCR9dyVX7sCDSzEFe O+ClnYz22m5jVhPoa1/cr3X0oDqsVYtiJp3Ov6+Dl+5KI+uFks2l/GiXe1jaARsRAwAbzT hefpp1QFZ2NVJzmf1ZPrHfkSXK/ayN1pHYAQSDHZBTiRjyoZW2FRP1qNNrj8560NVGj19k 0KBmzqgZoa+a40xh2626AAtDV3XQJWetRwz1xopkQULnNSWLDNgrSbYrbwBL5MXe0qqDxP ekMPjQyqj17VuE8eEzFe/kweHb/yu3jqit1dIEic4nl+0T3WWLObxMl9B7ksrw== 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 4bS5Qt1VPkz7cb; Wed, 25 Jun 2025 15:32:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 55PFW6Js069195; Wed, 25 Jun 2025 15:32:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 55PFW6IA069192; Wed, 25 Jun 2025 15:32:06 GMT (envelope-from git) Date: Wed, 25 Jun 2025 15:32:06 GMT Message-Id: <202506251532.55PFW6IA069192@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Warner Losh Subject: git: be9db83332 - main - git primer: Update info about rebasing in a few places List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-doc-all@freebsd.org Sender: owner-dev-commits-doc-all@FreeBSD.org 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: be9db83332da2904403179527cb829628f13113a Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/doc/commit/?id=be9db83332da2904403179527cb829628f13113a commit be9db83332da2904403179527cb829628f13113a Author: Warner Losh AuthorDate: 2024-12-04 17:05:49 +0000 Commit: Warner Losh CommitDate: 2025-06-25 15:31:27 +0000 git primer: Update info about rebasing in a few places Experience has shown that some of the advice in this primer is awkward and clunky. Address some of that by refining what we suggest. Sponsored by: Netflix --- .../en/articles/committers-guide/_index.adoc | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/documentation/content/en/articles/committers-guide/_index.adoc b/documentation/content/en/articles/committers-guide/_index.adoc index 90db1ecdf2..d52aab2ee5 100644 --- a/documentation/content/en/articles/committers-guide/_index.adoc +++ b/documentation/content/en/articles/committers-guide/_index.adoc @@ -1609,9 +1609,9 @@ The following answer assumes you committed to `main` and want to create a branch [source,shell] .... -% git branch issue # Create the 'issue' branch -% git reset --hard freebsd/main # Reset 'main' back to the official tip -% git checkout issue # Back to where you were +% git checkout -b issue # Create the 'issue' branch +% git checkout -B main freebsd/main # Reset main to upstream +% git checkout issue # Back to where you were .... ===== Ooops! I committed something to the wrong branch! @@ -1632,8 +1632,15 @@ It also assumes that it's the last commit on wilma (hence using wilma in the `gi % git reset --hard HEAD^ # move what wilma refers to back 1 commit .... -Git experts would first rewind the wilma branch by 1 commit, switch over to fred and then use `git reflog` to see what that 1 deleted commit was and -cherry-pick it over. +If it is not the last commit, you can cherry-pick that one change from wilma onto fred, then use `git rebase -i` to remove the change from wilma. + +[source,shell] +.... +# We're on branch wilma +% git checkout fred # move to fred branch +% git cherry-pick HASH_OF_CHANGE # copy the misplaced commit +% git rebase -i main wilma # drop the cherry-picked change +.... **Q:** But what if I want to commit a few changes to `main`, but keep the rest in `wilma` for some reason? @@ -1748,6 +1755,8 @@ How do I recover? **A:** This can happen when you invoke the pull with your development branch checked out. +Many developers use `git pull --rebase` to avoid this situation. + Right after the pull, you will have the new merge commit checked out. Git supports a `HEAD^#` syntax to examine the parents of a merge commit: @@ -1762,9 +1771,11 @@ Then you simply reset your branch to the corresponding `HEAD^#`: [source,shell] .... -git reset --hard HEAD^2 +git reset --hard HEAD^1 .... +In addition, a `git pull --rebase` at this stage will rebase your changes to 'main' to the latest 'freebsd/main'. + **Q:** But I also need to fix my `main` branch. How do I do that? **A:** Git keeps track of the remote repository branches in a `freebsd/` namespace.