Skip to content

Commit 6875c49

Browse files
jieyouxuNoratrieb
authored andcommitted
docs: document hard-resetting submodules
1 parent 5ec72a2 commit 6875c49

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/git.md

+31
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,37 @@ to know everything about submodules to contribute to Rust. Just know that they
566566
exist and that they correspond to some sort of embedded subrepository dependency
567567
that Git can nicely and fairly conveniently handle for us.
568568
569+
### Hard-resetting submodules
570+
571+
Sometimes you might run into (when you run `git status`)
572+
573+
```
574+
Changes not staged for commit:
575+
(use "git add <file>..." to update what will be committed)
576+
(use "git restore <file>..." to discard changes in working directory)
577+
(commit or discard the untracked or modified content in submodules)
578+
modified: src/llvm-project (new commits, modified content)
579+
```
580+
581+
and when you try to run `git submodule update` it breaks horribly with errors like
582+
583+
```
584+
error: RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly: CANCEL (err 8)
585+
error: 2782 bytes of body are still expected
586+
fetch-pack: unexpected disconnect while reading sideband packet
587+
fatal: early EOF
588+
fatal: fetch-pack: invalid index-pack output
589+
fatal: Fetched in submodule path 'src/llvm-project', but it did not contain 5a5152f653959d14d68613a3a8a033fb65eec021. Direct fetching of that commit failed.
590+
```
591+
592+
If you see `(new commits, modified content)` you can run
593+
594+
```bash
595+
$ git submodule foreach git reset --hard
596+
```
597+
598+
and then try `git submodule update` again.
599+
569600
[Git submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
570601
[`rust-lang/llvm-project`]: https://github.com/rust-lang/llvm-project
571602
[llvm-update]: https://github.com/rust-lang/rust/pull/99464/files

0 commit comments

Comments
 (0)