我如何恢复对git子模块的更改? [英] How do I revert my changes to a git submodule?
问题描述
我有一个git子模块(RestKit),我已经添加到我的回购站中。
I have a git submodule (RestKit) which I have added to my repo.
我意外地更改了那里的一些文件,我想回到源版本。为了做到这一点,我尝试运行
I accidentally changed some files in there and I'd like to go back to the source version. In order to do that, I tried to run
Mac:app-ios user$ git submodule update RestKit
但是,正如您在此处看到的,由于它仍然是修改的内容,因此无法正常工作:
But as you can see here, this did not work as it is still "modified content":
Mac:app-ios user$ git status
...
# modified: RestKit (modified content)
即使
Even
Mac:app-ios user$ git submodule update -f RestKit
不会恢复本地修改的文件。
如何重置该子模块的内容?
doesn't revert locally modified files.
How do I reset the content of that submodule?
推荐答案
移至子模块的目录,然后执行一个 git reset --hard
将所有修改后的文件重置为最后提交状态。请注意,这将丢弃所有未提交的更改。
Move into the submodule's directory, then do a git reset --hard
to reset all modified files to their last committed state. Be aware that this will discard all non-committed changes.
这篇关于我如何恢复对git子模块的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!