@@ -38,13 +38,13 @@ If you've cloned your fork, then you will be able to reference it with `origin`
38
38
in your local repo. It may be helpful to also set up a remote for the official
39
39
rust-lang/rust repo via
40
40
41
- ``` sh
41
+ ``` console
42
42
git remote add upstream https://github.com/rust-lang/rust.git
43
43
```
44
44
45
45
if you're using HTTPS, or
46
46
47
- ``` sh
47
+ ``` console
48
48
git remote add upstream git@github.com:rust-lang/rust.git
49
49
```
50
50
@@ -112,7 +112,7 @@ See [Rebasing](#rebasing) for more about rebasing.
112
112
This is not a problem from git's perspective. If you run ` git remote -v ` ,
113
113
it will say something like this:
114
114
115
- ```
115
+ ``` console
116
116
$ git remote -v
117
117
origin git@github.com:jyn514/rust.git (fetch)
118
118
origin git@github.com:jyn514/rust.git (push)
@@ -158,11 +158,11 @@ To fix it, do the following things:
158
158
### I see "error: cannot rebase" when I try to rebase
159
159
160
160
These are two common errors to see when rebasing:
161
- ```
161
+ ``` console
162
162
error: cannot rebase: Your index contains uncommitted changes.
163
163
error: Please commit or stash them.
164
164
```
165
- ```
165
+ ``` console
166
166
error: cannot rebase: You have unstaged changes.
167
167
error: Please commit or stash them.
168
168
```
@@ -174,7 +174,7 @@ commit your changes, or make a temporary commit called a "stash" to have them st
174
174
when you finish rebasing. You may want to configure git to make this "stash" automatically, which
175
175
will prevent the "cannot rebase" error in nearly all cases:
176
176
177
- ```
177
+ ``` console
178
178
git config --global rebase.autostash true
179
179
```
180
180
@@ -205,7 +205,7 @@ git reset --hard master
205
205
206
206
` git push ` will not work properly and say something like this:
207
207
208
- ```
208
+ ``` console
209
209
! [rejected] issue-xxxxx -> issue-xxxxx (non-fast-forward)
210
210
error: failed to push some refs to 'https://github.com/username/rust.git'
211
211
hint: Updates were rejected because the tip of your current branch is behind
@@ -226,7 +226,7 @@ didn't write, it likely means you're trying to rebase over the wrong branch. For
226
226
have a ` rust-lang/rust ` remote ` upstream ` , but ran ` git rebase origin/master ` instead of `git rebase
227
227
upstream/master`. The fix is to abort the rebase and use the correct branch instead:
228
228
229
- ```
229
+ ``` console
230
230
git rebase --abort
231
231
git rebase -i upstream/master
232
232
```
@@ -243,7 +243,7 @@ When updating your local repository with `git pull`, you may notice that sometim
243
243
Git says you have modified some files that you have never edited. For example,
244
244
running ` git status ` gives you something like (note the ` new commits ` mention):
245
245
246
- ```
246
+ ``` console
247
247
On branch master
248
248
Your branch is up to date with 'origin/master'.
249
249
@@ -256,9 +256,12 @@ Changes not staged for commit:
256
256
no changes added to commit (use "git add" and/or "git commit -a")
257
257
```
258
258
259
- These changes are not changes to files: they are changes to submodules (more on this
260
- [ later] ( #git-submodules ) ). To get rid of those, run ` ./x --help ` , which will automatically update
261
- the submodules.
259
+ These changes are not changes to files: they are changes to submodules (more on this [ later] ( #git-submodules ) ).
260
+ To get rid of those:
261
+
262
+ ``` console
263
+ git submodule update
264
+ ```
262
265
263
266
Some submodules are not actually needed; for example, ` src/llvm-project ` doesn't need to be checked
264
267
out if you're using ` download-ci-llvm ` . To avoid having to keep fetching its history, you can use
@@ -278,12 +281,12 @@ merged. To do that, you need to rebase your work on top of rust-lang/rust.
278
281
To rebase your feature branch on top of the newest version of the master branch
279
282
of rust-lang/rust, checkout your branch, and then run this command:
280
283
281
- ```
284
+ ``` console
282
285
git pull --rebase https://github.com/rust-lang/rust.git master
283
286
```
284
287
285
288
> If you are met with the following error:
286
- > ```
289
+ > ``` console
287
290
> error: cannot pull with rebase: Your index contains uncommitted changes.
288
291
> error: please commit or stash them.
289
292
> ` ` `
@@ -300,13 +303,13 @@ reapply the changes fails because your changes conflicted with other changes
300
303
that have been made. You can tell that this happened because you'll see
301
304
lines in the output that look like
302
305
303
- ```
306
+ ```console
304
307
CONFLICT (content): Merge conflict in file.rs
305
308
```
306
309
307
310
When you open these files, you'll see sections of the form
308
311
309
- ```
312
+ ``` console
310
313
<<<<<<< HEAD
311
314
Original code
312
315
=======
@@ -346,7 +349,7 @@ will keep it up-to-date. You will also want to rebase your feature branches
346
349
up-to-date as well. After pulling, you can checkout the feature branches
347
350
and rebase them:
348
351
349
- ```
352
+ ``` console
350
353
git checkout master
351
354
git pull upstream master --ff-only # to make certain there are no merge commits
352
355
git rebase master feature_branch
@@ -384,7 +387,7 @@ change the order in which they are applied, or "squash" them into each other.
384
387
385
388
Alternatively, you can sacrifice the commit history like this:
386
389
387
- ```
390
+ ``` console
388
391
# squash all the changes into one commit so you only have to worry about conflicts once
389
392
git rebase -i --keep-base master # and squash all changes along the way
390
393
git rebase master
@@ -422,7 +425,7 @@ it shows you the differences between your old diff and your new diff.
422
425
Here's an example of ` git range-diff ` output (taken from [ Git's
423
426
docs] [ range-diff-example-docs ] ):
424
427
425
- ```
428
+ ``` console
426
429
-: ------- > 1: 0ddba11 Prepare for the inevitable!
427
430
1: c0debee = 2: cab005e Add a helpful message at the start
428
431
2: f00dbal ! 3: decafe1 Describe a bug
@@ -499,7 +502,7 @@ Git and Github's default diff view for large moves *within* a file is quite poor
499
502
line as deleted and each line as added, forcing you to compare each line yourself. Git has an option
500
503
to show moved lines in a different color:
501
504
502
- ```
505
+ ``` console
503
506
git log -p --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change
504
507
```
505
508
@@ -515,7 +518,7 @@ that was force-pushed to make sure there are no unexpected changes.
515
518
Many large files in the repo are autogenerated. To view a diff that ignores changes to those files,
516
519
you can use the following syntax (e.g. Cargo.lock):
517
520
518
- ```
521
+ ``` console
519
522
git log -p ':!Cargo.lock'
520
523
```
521
524
@@ -545,7 +548,7 @@ The contents of submodules are ignored by Git: submodules are in some sense isol
545
548
from the rest of the repository. However, if you try to ` cd src/llvm-project ` and then
546
549
run ` git status ` :
547
550
548
- ```
551
+ ``` console
549
552
HEAD detached at 9567f08afc943
550
553
nothing to commit, working tree clean
551
554
```
@@ -576,7 +579,7 @@ that Git can nicely and fairly conveniently handle for us.
576
579
577
580
Sometimes you might run into (when you run ` git status ` )
578
581
579
- ```
582
+ ``` console
580
583
Changes not staged for commit:
581
584
(use "git add <file>..." to update what will be committed)
582
585
(use "git restore <file>..." to discard changes in working directory)
@@ -586,7 +589,7 @@ Changes not staged for commit:
586
589
587
590
and when you try to run ` git submodule update ` it breaks horribly with errors like
588
591
589
- ```
592
+ ``` console
590
593
error: RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly: CANCEL (err 8)
591
594
error: 2782 bytes of body are still expected
592
595
fetch-pack: unexpected disconnect while reading sideband packet
@@ -597,8 +600,8 @@ fatal: Fetched in submodule path 'src/llvm-project', but it did not contain 5a51
597
600
598
601
If you see ` (new commits, modified content) ` you can run
599
602
600
- ```bash
601
- $ git submodule foreach git reset --hard
603
+ ``` console
604
+ git submodule foreach git reset --hard
602
605
```
603
606
604
607
and then try ` git submodule update ` again.
@@ -607,7 +610,7 @@ and then try `git submodule update` again.
607
610
608
611
If that doesn't work, you can try to deinit all git submodules...
609
612
610
- ```
613
+ ``` console
611
614
git submodule deinit -f --all
612
615
```
613
616
@@ -618,7 +621,7 @@ completely messed up for some reason.
618
621
619
622
Sometimes, for some forsaken reason, you might run into
620
623
621
- ``` text
624
+ ``` console
622
625
fatal: not a git repository: src/gcc/../../.git/modules/src/gcc
623
626
```
624
627
0 commit comments