Git子模块和rebase [英] Git submodules and rebase

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

问题描述

使用git 1.8.1。我有git项目的上游和本地回购。它有一个子模块(散列A)。然后我在本地分支出它来分支功能(并有散列A子模块)。


  1. 将一些更改和子模块新哈希(B)拉入master分支。我的功能(与子模块散列A)对主分支(与子模块散列B)

当我从分支功能切换到分支主我看到submodule散列不受影响,仍然是B为主,A为功能。所以我需要每次手动更新它。



如何在不创建新提交的情况下将feature分支更新为新的子模块散列(B)?

解决方案

因此,您希望将整个子模块从 linux-kernel 更改为 emacs 并且让git没有注意到它,并且就像没有任何变化一样行事



Thats not 是可能的,因为每个提交都会注册自身所有子模块在提交时的提交(散列),并且您可以安全地假定每个git存储库中的每个提交都具有唯一的散列。因此,如果git在其任何子模块中找不到要提交的提交(例如,在 feature 分支的头部的hash B中),则git会投诉,以防子模块发生更改运行 git submodule update --init --recursive



我建议您先完成学习和了解子模块将它编织到您的工作流程中。

Using git 1.8.1. I have upstream and local repo for git project.It has one submodule (hash A). Then I branch it out locally to branch "feature" (and have hash A submodule).

  1. Pull some changes and submodule new hash (B) into master branch.
  2. Then I rebase my feature(with submodule hash A) against master branch (with submodule hash B)

When I switch from branch "feature" to branch "master" I see submodule hash is unaffected and still is B for master and A for feature. So I need to update it manually every time.

How can I update "feature" branch to new submodule hash (B) without creating new commit there?

解决方案

So you want to change the entire submodule from say the linux-kernel to emacs and have git not notice it and act as if nothing was changed?

Thats not possible because every commit registers with itself the commit(hash) at which all the submodule were when the commit was made and you can safely assume every commit in every git repository to-date has a unique hash. So git will complain if it doesn't find the commit it is looking for in any of its submodule(say in hash B at the HEAD of the feature branch), in case the submodule was changed and you run git submodule update --init --recursive.

I suggest first you throughly study and learn about submodule before weaving it into your workflow.

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

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