Skip to content

Commit 91332ec

Browse files
authored
Make git rebase commands more bulletproof (#1889)
1 parent aa79783 commit 91332ec

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Diff for: src/git.md

+16-6
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,26 @@ When you edit your code locally, you are making changes to the version of
270270
rust-lang/rust that existed when you created your feature branch. As such, when
271271
you submit your PR it is possible that some of the changes that have been made
272272
to rust-lang/rust since then are in conflict with the changes you've made.
273-
274273
When this happens, you need to resolve the conflicts before your changes can be
275-
merged. First, get a local copy of the conflicting changes: Checkout your local
276-
master branch with `git checkout master`, then `git pull upstream master` to
277-
update it with the most recent changes.
274+
merged. To do that, you need to rebase your work on top of rust-lang/rust.
278275

279276
### Rebasing
280277

281-
You're now ready to start the rebasing process. Checkout the branch with your
282-
changes and execute `git rebase master`.
278+
To rebase your feature branch on top of the newest version of the master branch
279+
of rust-lang/rust, checkout your branch, and then run this command:
280+
281+
```
282+
git pull --rebase https://github.com/rust-lang/rust.git master
283+
```
284+
285+
> If you are met with the following error:
286+
> ```
287+
> error: cannot pull with rebase: Your index contains uncommitted changes.
288+
> error: please commit or stash them.
289+
> ```
290+
> it means that you have some uncommitted work in your working tree. In that
291+
> case, run `git stash` before rebasing, and then `git stash pop` after you
292+
> have rebased and fixed all conflicts.
283293
284294
When you rebase a branch on master, all the changes on your branch are
285295
reapplied to the most recent version of master. In other words, Git tries to

0 commit comments

Comments
 (0)