Skip to content

Commit

Permalink
docs: document hard-resetting submodules
Browse files Browse the repository at this point in the history
  • Loading branch information
jieyouxu authored and Noratrieb committed Jun 19, 2024
1 parent 5ec72a2 commit 6875c49
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/git.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,37 @@ to know everything about submodules to contribute to Rust. Just know that they
exist and that they correspond to some sort of embedded subrepository dependency
that Git can nicely and fairly conveniently handle for us.

### Hard-resetting submodules

Sometimes you might run into (when you run `git status`)

```
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: src/llvm-project (new commits, modified content)
```

and when you try to run `git submodule update` it breaks horribly with errors like

```
error: RPC failed; curl 92 HTTP/2 stream 7 was not closed cleanly: CANCEL (err 8)
error: 2782 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output
fatal: Fetched in submodule path 'src/llvm-project', but it did not contain 5a5152f653959d14d68613a3a8a033fb65eec021. Direct fetching of that commit failed.
```

If you see `(new commits, modified content)` you can run

```bash
$ git submodule foreach git reset --hard
```

and then try `git submodule update` again.

[Git submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
[`rust-lang/llvm-project`]: https://github.com/rust-lang/llvm-project
[llvm-update]: https://github.com/rust-lang/rust/pull/99464/files

0 comments on commit 6875c49

Please sign in to comment.