签出过去的git子模块提交 [英] Checkout past git submodule commit

查看:104
本文介绍了签出过去的git子模块提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个有多个子模块的项目。昨天,一切都很好,应用程序正在运行等等。今天早上我运行 git submodules update 后,在应用程序中收到错误。

  $ git submodule update 
子模块路径'vendor / plugins / pluginA':签出'49d5cba84dcffc061db69813162d103feef31ecb'
子模块路径'vendor / plugins / pluginB':check out'4f442f0448c1826252933d5af8fb33cd64d76f6e'

那么我该如何检查以前的版本子模块(s),而我等待问题得到解决?我已经看到了几个参考解决方案,没有真正看到一个具体提到这种情况的例子。



谢谢!

编辑:如果您还可以帮助我理解/解决此问题(如何获取 pluginA pluginB

  $ git子模块状态
49d5cba84dcffc061db69813162d103feef31ecb供应商/插件/ pluginA(49d5cba)
4f442f0448c1826252933d5af8fb33cd64d76f6e供应商/插件/ pluginB(4f442f0)
558fd1a762d63562689e58cac50283192fde74d5供应商/插件/ pluginC(头/主)
4feb2c51148ebc4d4f80f9a64b9eabbfde5b13a3供应商/插件/ pluginD(头/主)
19dce61e256b0fc3f05342cdd3e4d21a434c0b87 vendor / plugins / pluginE(heads / master)


解决方案

  $ git submodule update 
子模块路径'vendor / plugins / pluginA':签出'49d5cba84dcffc061db69813162d103feef31ecb'
子模块路径'vendor / plugins / pluginB':签出'4f442f0448c1826252933d5af8fb33cd64d76f6e'

表示您已完成git pull,将文件和子模块提取并合并到项目中。
上游项目中的子模块的SHA1(您正在提取的子模块)已更改。



您可以在 projectA 内更改它们( git checkout aref ),然后 cd .. git add -A; git commit -madvance submodule to aref),并且推送(或不)将这些子模块返回到上游(如果需要的话)。

如果您需要知道在子模块更新之前您的子模块的确切SHA1是什么,只需执行 git show previousProjectSHA1 previousProjectSHA1 是您的主项目更新之前的前一个SHA1



您会看到类似于:

 新档案模式160000 
索引0000000..4c4c5a2

(4c4c5a2)是您需要将它们恢复到之前状态的子模块SHA1。



请参阅 git submodule update 这个问题来了解更多关于子模块的性质。


I am working on a project where there are a number of submodules. Yesterday, everything was peachy, app was running, etc. After I ran git submodules update this morning, I receive an error in the application.

$ git submodule update
Submodule path 'vendor/plugins/pluginA': checked out '49d5cba84dcffc061db69813162d103feef31ecb'
Submodule path 'vendor/plugins/pluginB': checked out '4f442f0448c1826252933d5af8fb33cd64d76f6e'

So how do I go about checking out the previous version of the submodule(s) while I wait for the issue to get fixed? I've seen several references to solutions without really seeing an example that specifically mentioned this case.

Thanks!

Edit: bonus if you can also help me understand/fix this (how to get the pluginA and pluginB to reference heads/master again):

$ git submodule status
49d5cba84dcffc061db69813162d103feef31ecb vendor/plugins/pluginA (49d5cba)
4f442f0448c1826252933d5af8fb33cd64d76f6e vendor/plugins/pluginB (4f442f0)
558fd1a762d63562689e58cac50283192fde74d5 vendor/plugins/pluginC (heads/master)
4feb2c51148ebc4d4f80f9a64b9eabbfde5b13a3 vendor/plugins/pluginD (heads/master)
19dce61e256b0fc3f05342cdd3e4d21a434c0b87 vendor/plugins/pluginE (heads/master)

解决方案

$ git submodule update
Submodule path 'vendor/plugins/pluginA': checked out '49d5cba84dcffc061db69813162d103feef31ecb'
Submodule path 'vendor/plugins/pluginB': checked out '4f442f0448c1826252933d5af8fb33cd64d76f6e'

means you have done a git pull, fetching and merging files and submodules to your project.
The SHA1 of those submodules in the upstream project (the one you have been pulling of) have changed.

You can change them back (git checkout aref within projectA, then cd .. and git add -A; git commit -m "advance submodule to aref" ), and push (or not) those submodules ref back to upstream if you want.

If you need to know what exact SHA1 was your submodule at before the submodule update, simply do a git show previousProjectSHA1 (previousProjectSHA1 being the previous SHA1 before your main project update

You will see something like:

new file mode 160000
index 0000000..4c4c5a2

That (4c4c5a2) is the submodule SHA1 you need to restore them to their previous state.

See git submodule update SO question to know more about the nature of submodules.

这篇关于签出过去的git子模块提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆