我如何“承诺”? git 子模块发生变化?
我天真地设置了一个 git 子模块并将其视为 Subversion 外部 - 即它现在充满了我刚刚意识到尚未提交或推送到任何地方的更改。
是否有一些简单的方法可以将子模块更改提交/推送回上游存储库? Git 中推荐的以这种方式在单独(但链接)存储库上进行同步开发的技术是什么?
I have, in my naivety, set up a git submodule and treated it like a Subversion external - i.e. it's now full of changes that I've just realized haven't been committed or pushed anywhere.
Is there some easy way to commit/push the submodule changes back to the upstream repo? And what's the recommended technique in Git for doing simultaneous development on separate (but linked) repositories in this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
子模块是它自己的存储库/工作区,有自己的
.git
目录。因此,首先
提交/推送
您的子模块更改:然后,更新您的主项目 跟踪子模块的更新版本:
A submodule is its own repo/work-area, with its own
.git
directory.So, first
commit/push
your submodule's changes:Then, update your main project to track the updated version of the submodule:
请注意,如果您在各个子模块中提交了一系列更改,您可以(或很快能够)一次性推送所有内容(即来自父模块的一次推送repo),其中:
git1.7.11([公告] Git 1.7.11.rc1) 提到:
可能是在此补丁 和
--on-demand
选项:此选项仅适用于一层嵌套。对另一个子模块内部的子模块的更改不会被推送。
Note that if you have committed a bunch of changes in various submodules, you can (or will be soon able to) push everything in one go (ie one push from the parent repo), with:
git1.7.11 ([ANNOUNCE] Git 1.7.11.rc1) mentions:
Probably done after this patch and the
--on-demand
option:This option only works for one level of nesting. Changes to the submodule inside of another submodule will not be pushed.
在这种情况下也是救命稻草。您可以使用它和 gitk --all 来跟踪您的 sha1 并验证您的子模块是否指向您认为的内容。
Is also a life saver in this situation. You can use it and
gitk --all
to keep track of your sha1's and verify your sub-modules are pointing at what you think they are.您可以像对待普通存储库一样对待子模块。要向上游传播您的更改,只需像通常在该目录中那样提交和推送即可。
You can treat a submodule exactly like an ordinary repository. To propagate your changes upstream just commit and push as you would normally within that directory.
在提交和推送之前,您需要为子模块初始化一个工作存储库树。
我正在使用 tortoise 并执行以下操作:
首先检查是否存在 .git 文件(不是目录)
如果有 .git 文件,那么肯定有 .git 目录跟踪本地树。
您仍然需要一个分支(您可以创建一个)或切换到主分支(有时不起作用)。
最好做的是
- git 获取
- git拉。不要省略 fetch。
现在您的提交和拉取将与您的 origin/master 同步
Before you can commit and push, you need to init a working repository tree for a submodule.
I am using tortoise and do following things:
First check if there exist .git file (not a directory)
If there was .git file, there surly was .git directory which tracks local tree.
You still need to a branch (you can create one) or switch to master (which sometimes does not work).
Best to do is
- git fetch
- git pull. Do not omit fetch.
Now your commits and pulls will be synchronized with your origin/master