@@ -46,14 +46,19 @@ git remote add upstream git@github.com:rust-lang/rust.git
4646
4747if you're using SSH.
4848
49+ ** NOTE:** This page is dedicated to workflows for ` rust-lang/rust ` , but will likely be
50+ useful when contributing to other repositories in the Rust project.
51+
52+
4953## Standard Process
5054
5155Below is the normal procedure that you're likely to use for most minor changes
5256and PRs:
5357
5458 1 . Ensure that you're making your changes on top of master:
5559 ` git checkout master ` .
56- 2 . Get the latest changes from the Rust repo: ` git pull upstream master ` .
60+ 2 . Get the latest changes from the Rust repo: ` git pull upstream master --ff-only ` .
61+ (see [ No-Merge Policy] ( #keeping-things-up-to-date ) for more info about this).
5762 3 . Make a new branch for your change: ` git checkout -b issue-12345-fix ` .
5863 4 . Make some changes to the repo and test them.
5964 5 . Stage your changes via ` git add src/changed/file.rs src/another/change.rs `
@@ -62,8 +67,13 @@ and PRs:
6267 unintentionally commit changes that should not be committed, such as submodule
6368 updates. You can use ` git status ` to check if there are any files you forgot
6469 to stage.
65- 6 . Push your changes to your fork: ` git push --set-upstream origin issue-12345-fix ` .
66- 7 . [ Open a PR] [ ghpullrequest ] from your fork to rust-lang/rust's master branch.
70+ 6 . Push your changes to your fork: ` git push --set-upstream origin issue-12345-fix `
71+ (After adding commits, you can use ` git push ` and after rebasing or
72+ pulling-and-rebasing, you can use ` git push --force-with-lease ` ).
73+ 7 . If you end up needing to rebase and are hitting conflicts, see [ Rebasing] ( #rebasing ) .
74+ 8 . If you want to track upstream while working on long-running feature/issue, see
75+ [ Keeping things up to date] ( #keeping-things-up-to-date ) .
76+ 9 . [ Open a PR] [ ghpullrequest ] from your fork to ` rust-lang/rust ` 's master branch.
6777
6878[ ghpullrequest ] : https://guides.github.com/activities/forking/#making-a-pull-request
6979
@@ -160,7 +170,7 @@ it's not anything you did wrong. There is a workaround at [#77620].
160170
161171[ #77620 ] : https://github.com/rust-lang/rust/issues/77620#issuecomment-705228229
162172
163- ## Conflicts
173+ ## Rebasing and Conflicts
164174
165175When you edit your code locally, you are making changes to the version of
166176rust-lang/rust that existed when you created your feature branch. As such, when
@@ -236,6 +246,34 @@ The advice this gives is incorrect! Because of Rust's
236246will not be allowed in the final PR, in addition to defeating the point of the
237247rebase! Use ` git push --force-with-lease ` instead.
238248
249+ ### Keeping things up to date
250+
251+ The above section on [ Rebasing] ( #rebasing ) is a specific
252+ guide on rebasing work and dealing with merge conflicts.
253+ Here is some general advice about how to keep your local repo
254+ up-to-date with upstream changes:
255+
256+ Using ` git pull upstream master ` while on your local master branch regularly
257+ will keep it up-to-date. You will also want to rebase your feature branches
258+ up-to-date as well. After pulling, you can checkout the feature branches
259+ and rebase them:
260+
261+ ```
262+ git checkout master
263+ git pull upstream master --ff-only # to make certain there are no merge commits
264+ git checkout feature_branch
265+ git rebase master
266+ git push --force-with-lease (set origin to be the same as local)
267+ ```
268+
269+ To avoid merges as per the [ No-Merge Policy] [ #no-merge-policy ] , you may want to use
270+ ` git config pull.ff only ` (this will apply the config to the local repo).
271+ to avoid merge conflicts while pulling, without needing
272+ ` --ff-only ` or ` --rebase ` while ` git pull ` ing
273+
274+ You can also ` git push --force-with-lease ` from master to keep your origin's master in sync with
275+ upstream.
276+
239277## Advanced Rebasing
240278
241279If your branch contains multiple consecutive rewrites of the same code, or if
@@ -330,6 +368,7 @@ that merge commits in PRs are not accepted. As a result, if you are running
330368course, this is not always true; if your merge will just be a fast-forward,
331369like the merges that ` git pull ` usually performs, then no merge commit is
332370created and you have nothing to worry about. Running ` git config merge.ff only `
371+ (this will apply the config to the local repo).
333372once will ensure that all the merges you perform are of this type, so that you
334373cannot make a mistake.
335374
0 commit comments