46
46
47
47
if you're using SSH.
48
48
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
+
49
53
## Standard Process
50
54
51
55
Below is the normal procedure that you're likely to use for most minor changes
52
56
and PRs:
53
57
54
58
1 . Ensure that you're making your changes on top of master:
55
59
` 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).
57
62
3 . Make a new branch for your change: ` git checkout -b issue-12345-fix ` .
58
63
4 . Make some changes to the repo and test them.
59
64
5 . Stage your changes via ` git add src/changed/file.rs src/another/change.rs `
@@ -62,8 +67,13 @@ and PRs:
62
67
unintentionally commit changes that should not be committed, such as submodule
63
68
updates. You can use ` git status ` to check if there are any files you forgot
64
69
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.
67
77
68
78
[ ghpullrequest ] : https://guides.github.com/activities/forking/#making-a-pull-request
69
79
@@ -160,7 +170,7 @@ it's not anything you did wrong. There is a workaround at [#77620].
160
170
161
171
[ #77620 ] : https://github.com/rust-lang/rust/issues/77620#issuecomment-705228229
162
172
163
- ## Conflicts
173
+ ## Rebasing and Conflicts
164
174
165
175
When you edit your code locally, you are making changes to the version of
166
176
rust-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
236
246
will not be allowed in the final PR, in addition to defeating the point of the
237
247
rebase! Use ` git push --force-with-lease ` instead.
238
248
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
+
239
277
## Advanced Rebasing
240
278
241
279
If 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
330
368
course, this is not always true; if your merge will just be a fast-forward,
331
369
like the merges that ` git pull ` usually performs, then no merge commit is
332
370
created and you have nothing to worry about. Running ` git config merge.ff only `
371
+ (this will apply the config to the local repo).
333
372
once will ensure that all the merges you perform are of this type, so that you
334
373
cannot make a mistake.
335
374
0 commit comments