Git子模块还原提交 [英] Git submodule revert commit

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

问题描述

我在Git项目super中有一个子模块sub.现在有super的多个分支,每个分支都可以指向sub的另一个提交.通过

I have a submodule sub in a Git project super. Now there are multiple branches of super and each may point to another commit of sub. Changing the branch of super via

>$ git checkout <branchname>

但是,

不能正确地适应sub来再次指向正确的提交.取而代之的是

does not properly adapt sub to point to the correct commit again, though. Instead the result of

>$ git status

包含sub修改条目.

这只是几种情况下的一种,其中一种情况可能需要还原对sub的任何修改并检出super实际指向的提交.

This is only one of several situations where one might want to revert any modifications of sub and checkout the commit to which super actually points.

对于文件,您可以随时运行

For files you can always run

>$ git checkout -- path/to/file

还原任何修改.因此,我基本上是在寻找一个等效的调用,以一种类似的快速简便的方式还原子模块.

to revert any modifications. So I am basically looking for an equivalent call to revert submodules in a similarly quick and simple manner.

我知道这可以通过两个命令的组合来实现:

I know this is possible by combination of two commands:

>$ git submodule deinit -f /path/to/sub
>$ git submodule update --init --recursive /path/to/sub

但是我正在寻找一个较短的版本,该版本可能更容易记住并且可以更快地输入;)

but I am looking for a shorter version which might be easier to remember and faster to type ;)

您有什么建议吗?

推荐答案

如torek所述,跳过deinit步骤效果很好.因此,以下命令为我完成了工作:

As mentioned by torek, skipping the deinit step works well. Thus the following command does the job for me:

git submodule update --recursive /path/to/submodule

谢谢大家的回答!

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

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