@@ -103,7 +103,7 @@ Here are some common issues you might run into:
103
103
104
104
Git has two ways to update your branch with the newest changes: merging and rebasing.
105
105
Rust [ uses rebasing] [ no-merge-policy ] . If you make a merge commit, it's not too hard to fix:
106
- ` git rebase -i origin /master ` .
106
+ ` git rebase -i upstream /master ` .
107
107
108
108
See [ Rebasing] [ #rebasing ] for more about rebasing.
109
109
@@ -114,16 +114,16 @@ it will say something like this:
114
114
115
115
```
116
116
$ git remote -v
117
- origin https:// github.com// rust-lang/rust (fetch)
118
- origin https:// github.com// rust-lang/rust (push)
119
- personal https://github.com/jyn514 /rust (fetch)
120
- personal https://github.com/jyn514 /rust (push )
117
+ origin git@ github.com:jyn514/ rust.git (fetch)
118
+ origin git@ github.com:jyn514/ rust.git (push)
119
+ upstream https://github.com/rust-lang /rust (fetch)
120
+ upstream https://github.com/rust-lang /rust (fetch )
121
121
```
122
122
123
123
If you renamed your fork, you can change the URL like this:
124
124
125
125
``` console
126
- git remote set-url personal <URL>
126
+ git remote set-url origin <URL>
127
127
```
128
128
129
129
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
174
174
git reset --hard master
175
175
```
176
176
177
+ ### Git is trying to rebase commits I didn't write?
178
+
179
+ If you see many commits in your rebase list, or merge commits, or commits by other people that you
180
+ didn't write, it likely means you're trying to rebase over the wrong branch. For example, you may
181
+ have a ` rust-lang/rust ` remote ` upstream ` , but ran ` git rebase origin/master ` instead of `git rebase
182
+ upstream/master`. The fix is to abort the rebase and use the correct branch instead:
183
+
184
+ ```
185
+ git rebase --abort
186
+ git rebase -i upstream/master
187
+ ```
188
+
189
+ <details ><summary >Click here to see an example of rebasing over the wrong branch</summary >
190
+
191
+ ![ Interactive rebase over the wrong branch] ( img/other-peoples-commits.png )
192
+
193
+ </details >
194
+
177
195
### Quick note about submodules
178
196
179
197
When updating your local repository with ` git pull ` , you may notice that sometimes
@@ -308,17 +326,16 @@ and rebase them:
308
326
```
309
327
git checkout master
310
328
git pull upstream master --ff-only # to make certain there are no merge commits
311
- git checkout feature_branch
312
- git rebase master
313
- git push --force-with-lease (set origin to be the same as local)
329
+ git rebase master feature_branch
330
+ git push --force-with-lease # (set origin to be the same as local)
314
331
```
315
332
316
333
To avoid merges as per the [ No-Merge Policy] ( #no-merge-policy ) , you may want to use
317
334
` git config pull.ff only ` (this will apply the config only to the local repo)
318
335
to ensure that Git doesn't create merge commits when ` git pull ` ing, without
319
336
needing to pass ` --ff-only ` or ` --rebase ` every time.
320
337
321
- You can also ` git push --force-with-lease ` from master to keep your origin 's master in sync with
338
+ You can also ` git push --force-with-lease ` from master to keep your fork 's master in sync with
322
339
upstream.
323
340
324
341
## Advanced Rebasing
0 commit comments