summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorJoshua Nelson <github@jyn.dev>2022-12-29 11:06:48 -0600
committerJoshua Nelson <github@jyn.dev>2022-12-29 11:39:24 -0600
commit7092374bcc50c4085c658b7988424d33ab2ca077 (patch)
tree80f35c4bdd896821f6bd332427b86d50bd2e6eb7 /src/doc/rustc-dev-guide
parent6ba4f9ca0c6277f6e6833b1296abf58894efbc8a (diff)
downloadrust-7092374bcc50c4085c658b7988424d33ab2ca077.tar.gz
rust-7092374bcc50c4085c658b7988424d33ab2ca077.zip
Use `origin` consistently and add an example of rebasing over the wrong remote
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/src/git.md37
-rw-r--r--src/doc/rustc-dev-guide/src/img/other-peoples-commits.pngbin0 -> 301512 bytes
2 files changed, 27 insertions, 10 deletions
diff --git a/src/doc/rustc-dev-guide/src/git.md b/src/doc/rustc-dev-guide/src/git.md
index 44f685c9547..a038880a736 100644
--- a/src/doc/rustc-dev-guide/src/git.md
+++ b/src/doc/rustc-dev-guide/src/git.md
@@ -103,7 +103,7 @@ Here are some common issues you might run into:
 
 Git has two ways to update your branch with the newest changes: merging and rebasing.
 Rust [uses rebasing][no-merge-policy]. If you make a merge commit, it's not too hard to fix:
-`git rebase -i origin/master`.
+`git rebase -i upstream/master`.
 
 See [Rebasing][#rebasing] for more about rebasing.
 
@@ -114,16 +114,16 @@ it will say something like this:
 
 ```
 $ git remote -v
-origin	https://github.com//rust-lang/rust (fetch)
-origin	https://github.com//rust-lang/rust (push)
-personal	https://github.com/jyn514/rust (fetch)
-personal	https://github.com/jyn514/rust (push)
+origin  git@github.com:jyn514/rust.git (fetch)
+origin  git@github.com:jyn514/rust.git (push)
+upstream        https://github.com/rust-lang/rust (fetch)
+upstream        https://github.com/rust-lang/rust (fetch)
 ```
 
 If you renamed your fork, you can change the URL like this:
 
 ```console
-git remote set-url personal <URL>
+git remote set-url origin <URL>
 ```
 
 where the `<URL>` is your new fork.
@@ -174,6 +174,24 @@ and just want to get a clean copy of the repository back, you can use `git reset
 git reset --hard master
 ```
 
+### Git is trying to rebase commits I didn't write?
+
+If you see many commits in your rebase list, or merge commits, or commits by other people that you
+didn't write, it likely means you're trying to rebase over the wrong branch. For example, you may
+have a `rust-lang/rust` remote `upstream`, but ran `git rebase origin/master` instead of `git rebase
+upstream/master`. The fix is to abort the rebase and use the correct branch instead:
+
+```
+git rebase --abort
+git rebase -i upstream/master
+```
+
+<details><summary>Click here to see an example of rebasing over the wrong branch</summary>
+
+![Interactive rebase over the wrong branch](img/other-peoples-commits.png)
+
+</details>
+
 ### Quick note about submodules
 
 When updating your local repository with `git pull`, you may notice that sometimes
@@ -308,9 +326,8 @@ and rebase them:
 ```
 git checkout master
 git pull upstream master --ff-only # to make certain there are no merge commits
-git checkout feature_branch
-git rebase master
-git push --force-with-lease (set origin to be the same as local)
+git rebase master feature_branch
+git push --force-with-lease # (set origin to be the same as local)
 ```
 
 To avoid merges as per the [No-Merge Policy](#no-merge-policy), you may want to use
@@ -318,7 +335,7 @@ To avoid merges as per the [No-Merge Policy](#no-merge-policy), you may want to
 to ensure that Git doesn't create merge commits when `git pull`ing, without
 needing to pass `--ff-only` or `--rebase` every time.
 
-You can also `git push --force-with-lease` from master to keep your origin's master in sync with
+You can also `git push --force-with-lease` from master to keep your fork's master in sync with
 upstream.
 
 ## Advanced Rebasing
diff --git a/src/doc/rustc-dev-guide/src/img/other-peoples-commits.png b/src/doc/rustc-dev-guide/src/img/other-peoples-commits.png
new file mode 100644
index 00000000000..e4fc2c7972e
--- /dev/null
+++ b/src/doc/rustc-dev-guide/src/img/other-peoples-commits.png
Binary files differ