aboutsummaryrefslogtreecommitdiff
path: root/documentation/content/en/articles
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2024-12-04 17:05:49 +0000
committerWarner Losh <imp@FreeBSD.org>2025-06-25 15:31:27 +0000
commitbe9db83332da2904403179527cb829628f13113a (patch)
treefe55ad94983f594a22dda1f5baf3c223b8c75ba2 /documentation/content/en/articles
parent7872626fddda5bd3c8406fcf2ac7e92d30605619 (diff)
Diffstat (limited to 'documentation/content/en/articles')
-rw-r--r--documentation/content/en/articles/committers-guide/_index.adoc23
1 files 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.