@@ -38,13 +38,13 @@ If you've cloned your fork, then you will be able to reference it with `origin`
3838in your local repo. It may be helpful to also set up a remote for the official
3939rust-lang/rust repo via
4040
41- ``` sh
41+ ``` console
4242git remote add upstream https://github.com/rust-lang/rust.git
4343```
4444
4545if you're using HTTPS, or
4646
47- ``` sh
47+ ``` console
4848git remote add upstream [email protected] :rust-lang/rust.git 4949```
5050
@@ -112,7 +112,7 @@ See [Rebasing](#rebasing) for more about rebasing.
112112This is not a problem from git's perspective. If you run ` git remote -v ` ,
113113it will say something like this:
114114
115- ```
115+ ``` console
116116$ git remote -v
117117origin [email protected] :jyn514/rust.git (fetch) 118118origin [email protected] :jyn514/rust.git (push) @@ -158,11 +158,11 @@ To fix it, do the following things:
158158### I see "error: cannot rebase" when I try to rebase
159159
160160These are two common errors to see when rebasing:
161- ```
161+ ``` console
162162error: cannot rebase: Your index contains uncommitted changes.
163163error: Please commit or stash them.
164164```
165- ```
165+ ``` console
166166error: cannot rebase: You have unstaged changes.
167167error: Please commit or stash them.
168168```
@@ -174,7 +174,7 @@ commit your changes, or make a temporary commit called a "stash" to have them st
174174when you finish rebasing. You may want to configure git to make this "stash" automatically, which
175175will prevent the "cannot rebase" error in nearly all cases:
176176
177- ```
177+ ``` console
178178git config --global rebase.autostash true
179179```
180180
@@ -205,7 +205,7 @@ git reset --hard master
205205
206206` git push ` will not work properly and say something like this:
207207
208- ```
208+ ``` console
209209 ! [rejected] issue-xxxxx -> issue-xxxxx (non-fast-forward)
210210error: failed to push some refs to 'https://github.com/username/rust.git'
211211hint: 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
226226have a ` rust-lang/rust ` remote ` upstream ` , but ran ` git rebase origin/master ` instead of `git rebase
227227upstream/master`. The fix is to abort the rebase and use the correct branch instead:
228228
229- ```
229+ ``` console
230230git rebase --abort
231231git rebase -i upstream/master
232232```
@@ -243,7 +243,7 @@ When updating your local repository with `git pull`, you may notice that sometim
243243Git says you have modified some files that you have never edited. For example,
244244running ` git status ` gives you something like (note the ` new commits ` mention):
245245
246- ```
246+ ``` console
247247On branch master
248248Your branch is up to date with 'origin/master'.
249249
@@ -256,9 +256,12 @@ Changes not staged for commit:
256256no changes added to commit (use "git add" and/or "git commit -a")
257257```
258258
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+ ```
262265
263266Some submodules are not actually needed; for example, ` src/llvm-project ` doesn't need to be checked
264267out 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.
278281To rebase your feature branch on top of the newest version of the master branch
279282of rust-lang/rust, checkout your branch, and then run this command:
280283
281- ```
284+ ``` console
282285git pull --rebase https://github.com/rust-lang/rust.git master
283286```
284287
285288> If you are met with the following error:
286- > ```
289+ > ``` console
287290> error: cannot pull with rebase: Your index contains uncommitted changes.
288291> error: please commit or stash them.
289292> ` ` `
@@ -300,13 +303,13 @@ reapply the changes fails because your changes conflicted with other changes
300303that have been made. You can tell that this happened because you'll see
301304lines in the output that look like
302305
303- ```
306+ ```console
304307CONFLICT (content): Merge conflict in file.rs
305308```
306309
307310When you open these files, you'll see sections of the form
308311
309- ```
312+ ``` console
310313<<<<<<< HEAD
311314Original code
312315=======
@@ -346,7 +349,7 @@ will keep it up-to-date. You will also want to rebase your feature branches
346349up-to-date as well. After pulling, you can checkout the feature branches
347350and rebase them:
348351
349- ```
352+ ``` console
350353git checkout master
351354git pull upstream master --ff-only # to make certain there are no merge commits
352355git rebase master feature_branch
@@ -384,7 +387,7 @@ change the order in which they are applied, or "squash" them into each other.
384387
385388Alternatively, you can sacrifice the commit history like this:
386389
387- ```
390+ ``` console
388391# squash all the changes into one commit so you only have to worry about conflicts once
389392git rebase -i --keep-base master # and squash all changes along the way
390393git rebase master
@@ -422,7 +425,7 @@ it shows you the differences between your old diff and your new diff.
422425Here's an example of ` git range-diff ` output (taken from [ Git's
423426docs] [ range-diff-example-docs ] ):
424427
425- ```
428+ ``` console
426429-: ------- > 1: 0ddba11 Prepare for the inevitable!
4274301: c0debee = 2: cab005e Add a helpful message at the start
4284312: 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
499502line as deleted and each line as added, forcing you to compare each line yourself. Git has an option
500503to show moved lines in a different color:
501504
502- ```
505+ ``` console
503506git log -p --color-moved=dimmed-zebra --color-moved-ws=allow-indentation-change
504507```
505508
@@ -515,7 +518,7 @@ that was force-pushed to make sure there are no unexpected changes.
515518Many large files in the repo are autogenerated. To view a diff that ignores changes to those files,
516519you can use the following syntax (e.g. Cargo.lock):
517520
518- ```
521+ ``` console
519522git log -p ':!Cargo.lock'
520523```
521524
@@ -545,7 +548,7 @@ The contents of submodules are ignored by Git: submodules are in some sense isol
545548from the rest of the repository. However, if you try to ` cd src/llvm-project ` and then
546549run ` git status ` :
547550
548- ```
551+ ``` console
549552HEAD detached at 9567f08afc943
550553nothing to commit, working tree clean
551554```
@@ -576,7 +579,7 @@ that Git can nicely and fairly conveniently handle for us.
576579
577580Sometimes you might run into (when you run ` git status ` )
578581
579- ```
582+ ``` console
580583Changes not staged for commit:
581584 (use "git add <file>..." to update what will be committed)
582585 (use "git restore <file>..." to discard changes in working directory)
@@ -586,7 +589,7 @@ Changes not staged for commit:
586589
587590and when you try to run ` git submodule update ` it breaks horribly with errors like
588591
589- ```
592+ ``` console
590593error: RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly: CANCEL (err 8)
591594error: 2782 bytes of body are still expected
592595fetch-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
597600
598601If you see ` (new commits, modified content) ` you can run
599602
600- ```bash
601- $ git submodule foreach git reset --hard
603+ ``` console
604+ git submodule foreach git reset --hard
602605```
603606
604607and then try ` git submodule update ` again.
@@ -607,7 +610,7 @@ and then try `git submodule update` again.
607610
608611If that doesn't work, you can try to deinit all git submodules...
609612
610- ```
613+ ``` console
611614git submodule deinit -f --all
612615```
613616
@@ -618,7 +621,7 @@ completely messed up for some reason.
618621
619622Sometimes, for some forsaken reason, you might run into
620623
621- ``` text
624+ ``` console
622625fatal: not a git repository: src/gcc/../../.git/modules/src/gcc
623626```
624627
0 commit comments