@@ -57,9 +57,9 @@ useful when contributing to other repositories in the Rust project.
5757Below is the normal procedure that you're likely to use for most minor changes
5858and PRs:
5959
60- 1 . Ensure that you're making your changes on top of master :
61- ` git checkout master ` .
62- 2 . Get the latest changes from the Rust repo: ` git pull upstream master --ff-only ` .
60+ 1 . Ensure that you're making your changes on top of main :
61+ ` git checkout main ` .
62+ 2 . Get the latest changes from the Rust repo: ` git pull upstream main --ff-only ` .
6363 (see [ No-Merge Policy] [ no-merge-policy ] for more info about this).
6464 3 . Make a new branch for your change: ` git checkout -b issue-12345-fix ` .
6565 4 . Make some changes to the repo and test them.
@@ -72,7 +72,7 @@ and PRs:
7272 6 . Push your changes to your fork: ` git push --set-upstream origin issue-12345-fix `
7373 (After adding commits, you can use ` git push ` and after rebasing or
7474pulling-and-rebasing, you can use ` git push --force-with-lease ` ).
75- 7 . [ Open a PR] [ ghpullrequest ] from your fork to ` rust-lang/rust ` 's master branch.
75+ 7 . [ Open a PR] [ ghpullrequest ] from your fork to ` rust-lang/rust ` 's main branch.
7676
7777[ ghpullrequest ] : https://guides.github.com/activities/forking/#making-a-pull-request
7878
@@ -101,7 +101,7 @@ Here are some common issues you might run into:
101101
102102Git has two ways to update your branch with the newest changes: merging and rebasing.
103103Rust [ uses rebasing] [ no-merge-policy ] . If you make a merge commit, it's not too hard to fix:
104- ` git rebase -i upstream/master ` .
104+ ` git rebase -i upstream/main ` .
105105
106106See [ Rebasing] ( #rebasing ) for more about rebasing.
107107
@@ -151,7 +151,7 @@ replace `src/tools/cargo` with the path to that submodule):
151151 - If you modified the submodule in several different commits, you will need to repeat steps 1-3
152152 for each commit you modified. You'll know when to stop when the ` git log ` command shows a commit
153153 that's not authored by you.
154- 5 . Squash your changes into the existing commits: ` git rebase --autosquash -i upstream/master `
154+ 5 . Squash your changes into the existing commits: ` git rebase --autosquash -i upstream/main `
1551556 . [ Push your changes] ( #standard-process ) .
156156
157157### I see "error: cannot rebase" when I try to rebase
@@ -197,7 +197,7 @@ and just want to get a clean copy of the repository back, you can use `git reset
197197
198198``` console
199199# WARNING: this throws out any local changes you' ve made! Consider resolving the conflicts instead.
200- git reset --hard master
200+ git reset --hard main
201201```
202202
203203### failed to push some refs
@@ -222,12 +222,12 @@ rebase! Use `git push --force-with-lease` instead.
222222
223223If you see many commits in your rebase list, or merge commits, or commits by other people that you
224224didn't write, it likely means you're trying to rebase over the wrong branch. For example, you may
225- have a ` rust-lang/rust ` remote ` upstream ` , but ran ` git rebase origin/master ` instead of `git rebase
226- upstream/master `. The fix is to abort the rebase and use the correct branch instead:
225+ have a ` rust-lang/rust ` remote ` upstream ` , but ran ` git rebase origin/main ` instead of `git rebase
226+ upstream/main `. The fix is to abort the rebase and use the correct branch instead:
227227
228228``` console
229229git rebase --abort
230- git rebase -i upstream/master
230+ git rebase --interactive upstream/main
231231```
232232
233233<details ><summary >Click here to see an example of rebasing over the wrong branch</summary >
@@ -243,8 +243,8 @@ Git says you have modified some files that you have never edited. For example,
243243running ` git status ` gives you something like (note the ` new commits ` mention):
244244
245245``` console
246- On branch master
247- Your branch is up to date with 'origin/master '.
246+ On branch main
247+ Your branch is up to date with 'origin/main '.
248248
249249Changes not staged for commit:
250250 (use "git add <file>..." to update what will be committed)
@@ -277,11 +277,11 @@ merged. To do that, you need to rebase your work on top of rust-lang/rust.
277277
278278### Rebasing
279279
280- To rebase your feature branch on top of the newest version of the master branch
280+ To rebase your feature branch on top of the newest version of the main branch
281281of rust-lang/rust, checkout your branch, and then run this command:
282282
283283``` console
284- git pull --rebase https://github.com/rust-lang/rust.git master
284+ git pull --rebase https://github.com/rust-lang/rust.git main
285285```
286286
287287> If you are met with the following error:
@@ -293,10 +293,10 @@ git pull --rebase https://github.com/rust-lang/rust.git master
293293> case, run ` git stash` before rebasing, and then ` git stash pop` after you
294294> have rebased and fixed all conflicts.
295295
296- When you rebase a branch on master , all the changes on your branch are
297- reapplied to the most recent version of master . In other words, Git tries to
298- pretend that the changes you made to the old version of master were instead
299- made to the new version of master . During this process, you should expect to
296+ When you rebase a branch on main , all the changes on your branch are
297+ reapplied to the most recent version of main . In other words, Git tries to
298+ pretend that the changes you made to the old version of main were instead
299+ made to the new version of main . During this process, you should expect to
300300encounter at least one "rebase conflict." This happens when Git's attempt to
301301reapply the changes fails because your changes conflicted with other changes
302302that have been made. You can tell that this happened because you'll see
@@ -318,9 +318,9 @@ Your code
318318
319319This represents the lines in the file that Git could not figure out how to
320320rebase. The section between ` <<<<<<< HEAD ` and ` ======= ` has the code from
321- master , while the other side has your version of the code. You'll need to
321+ main , while the other side has your version of the code. You'll need to
322322decide how to deal with the conflict. You may want to keep your changes,
323- keep the changes on master , or combine the two.
323+ keep the changes on main , or combine the two.
324324
325325Generally, resolving the conflict consists of two steps: First, fix the
326326particular conflict. Edit the file to make the changes you want and remove the
@@ -343,15 +343,15 @@ guide on rebasing work and dealing with merge conflicts.
343343Here is some general advice about how to keep your local repo
344344up-to-date with upstream changes:
345345
346- Using ` git pull upstream master ` while on your local master branch regularly
346+ Using ` git pull upstream main ` while on your local main branch regularly
347347will keep it up-to-date. You will also want to keep your feature branches
348348up-to-date as well. After pulling, you can checkout the feature branches
349349and rebase them:
350350
351351``` console
352- git checkout master
353- git pull upstream master --ff-only # to make certain there are no merge commits
354- git rebase master feature_branch
352+ git checkout main
353+ git pull upstream main --ff-only # to make certain there are no merge commits
354+ git rebase main feature_branch
355355git push --force-with-lease # (set origin to be the same as local)
356356```
357357
@@ -360,7 +360,7 @@ To avoid merges as per the [No-Merge Policy](#no-merge-policy), you may want to
360360to ensure that Git doesn't create merge commits when ` git pull ` ing, without
361361needing to pass ` --ff-only ` or ` --rebase ` every time.
362362
363- You can also ` git push --force-with-lease ` from master to double-check that your
363+ You can also ` git push --force-with-lease ` from main to double-check that your
364364feature branches are in sync with their state on the Github side.
365365
366366## Advanced Rebasing
@@ -373,23 +373,23 @@ On the one hand, you lose track of the steps in which changes were made, but
373373the history becomes easier to work with.
374374
375375If there are no conflicts and you are just squashing to clean up the history,
376- use ` git rebase --interactive --keep-base master ` . This keeps the fork point
376+ use ` git rebase --interactive --keep-base main ` . This keeps the fork point
377377of your PR the same, making it easier to review the diff of what happened
378378across your rebases.
379379
380380Squashing can also be useful as part of conflict resolution.
381381If your branch contains multiple consecutive rewrites of the same code, or if
382382the rebase conflicts are extremely severe, you can use
383- ` git rebase --interactive master ` to gain more control over the process. This
383+ ` git rebase --interactive main ` to gain more control over the process. This
384384allows you to choose to skip commits, edit the commits that you do not skip,
385385change the order in which they are applied, or "squash" them into each other.
386386
387387Alternatively, you can sacrifice the commit history like this:
388388
389389``` console
390390# squash all the changes into one commit so you only have to worry about conflicts once
391- git rebase -i --keep-base master # and squash all changes along the way
392- git rebase master
391+ git rebase --interactive --keep-base main # and squash all changes along the way
392+ git rebase main
393393# fix all merge conflicts
394394git rebase --continue
395395```
@@ -402,9 +402,9 @@ because they only represent "fixups" and not real changes. For example,
402402
403403After completing a rebase, and before pushing up your changes, you may want to
404404review the changes between your old branch and your new one. You can do that
405- with ` git range-diff master @{upstream} HEAD ` .
405+ with ` git range-diff main @{upstream} HEAD ` .
406406
407- The first argument to ` range-diff ` , ` master ` in this case, is the base revision
407+ The first argument to ` range-diff ` , ` main ` in this case, is the base revision
408408that you're comparing your old and new branch against. The second argument is
409409the old version of your branch; in this case, ` @upstream ` means the version that
410410you've pushed to GitHub, which is the same as what people will see in your pull
@@ -413,7 +413,7 @@ your branch; in this case, it is `HEAD`, which is the commit that is currently
413413checked-out in your local repo.
414414
415415Note that you can also use the equivalent, abbreviated form `git range-diff
416- master @{u} HEAD`.
416+ main @{u} HEAD`.
417417
418418Unlike in regular Git diffs, you'll see a ` - ` or ` + ` next to another ` - ` or ` + `
419419in the range-diff output. The marker on the left indicates a change between the
@@ -481,7 +481,7 @@ to follow and understand.
481481### Hiding whitespace
482482
483483Github has a button for disabling whitespace changes that may be useful.
484- You can also use ` git diff -w origin/master ` to view changes locally.
484+ You can also use ` git diff -w origin/main ` to view changes locally.
485485
486486![ hide whitespace] ( ./img/github-whitespace-changes.png )
487487
0 commit comments