我最近在我的暂存分支中运行了 git 子模块 init
和 update
提交。这导致 git 从子模块下载了一堆更改,我不想将这些更改放入暂存阶段并希望完全丢弃。
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: path-to/submodule1 (modified content)
modified: path-to/submodule2 (new commits,modified content)
…
no changes added to commit (use "git add" and/or "git commit -a")
我想放弃所有这些更改,并且不向当前分支添加任何内容。我该怎么做?
最佳答案
由于每个子模块都是其自己的 Git 存储库,因此您可以单独重置每个子模块。
删除任何未提交的本地更改:进入每个子模块,然后运行
git reset --hard
通过在顶级运行
git submodule update
来确保每个子模块都位于顶级 Git 存储库所需的提交上。
关于git - 如何丢弃 git 子模块中修改的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70302679/