git stash 会重置子模块吗?

发布于 2025-01-12 12:00:47 字数 612 浏览 2 评论 0原文

我是 git 新手。我想隐藏我的更改并在我的分支上执行 git pull origin master 。我正在开发的项目有子模块。

这些是我运行的命令:

  1. git status - 我可以看到我的所有更改(子模块+主项目)

  2. git stash push 没有错误或警告。我在项目的主目录中运行了它

  3. git status - 所有更改都消失了(包括子模块)

  4. git pull origin master - 有效(由于我们环境中的某些配置,也更新了子模块)

  5. git stash pop - 没有错误或警告

  6. git status - 子模块中完成的所有工作都消失了。

发生了什么 ?我知道 git stash 将为我隐藏的工作进行提交,然后执行 git git reset --hard 。为什么我的子模块工作消失了?如何正确地存储带有子模块的项目?

谢谢

I'm new to git. I wanted to stash my changes and do a git pull origin master on my branch. The project that I'm working on has submodules.

Those are the commands I ran :

  1. git status - I can see all of my changes ( submodules + the main project )

  2. git stash push no errors or warnings. I ran this in the main directory of my project

  3. git status - All of the changes are gone ( submodules include )

  4. git pull origin master - works ( updates the submodules as well due to some configuration in our environment )

  5. git stash pop - no errors or warnings

  6. git status - all the work done in the submodules is gone.

What happened ? I know that git stash is going to make commits for my stashed work and after that do a git git reset --hard. Why is my submodule work gone ? How do you correctly stash a project with submodules ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2025-01-19 12:00:47

git stash 会重置子模块吗?

不,git stash push 不会保存子模块内的更改(请参阅此问题文档根本没有提及子模块),因此它不会恢复这些子模块变化。

Will git stash reset submodules?

No, git stash push does not save the changes within submodules (see this question and the documentation that does not mention submodules at all) and it therefore does not revert those changes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文