问题描述
我正在一个项目中使用git submodules来跟踪整个代码(几个不同的部分一起发布),所以我喜欢这样的想法,即子模块跟踪特定的提交,因为哪些子模块将主要用于是历史的目的。
这很好,以便将来可以检出超级回购的特定标签,并找出每个组件的代码位置。但是,如果突然之间想要对该特定版本执行一些更多提交,则会出现问题,因为由于您处于无头状态,因此没有真正的方法可以找出提交属于哪个分支。
跟踪分支,如1.8.2中所添加的,似乎无法解决这个问题,无论是从我能读取的内容,因为它只是检查分支中的最新提交,可能不是什么当时已经发布了。
有没有什么方法可以混合使用2来检查超级回购,并查看哪些提交了所有内容,但仍然可以跟踪到一个分支,以便他确切地知道哪个分支(从他们可能已经更多的承诺到该分支)并继续对它进行承诺?
我猜我我在寻找的是以某种方式让git落在一个状态,就好像开发人员有几个提交从服务器上拉下来一样,他的本地repo头在正确的提交,但服务器已经提前,这样他c应该确切地知道他在哪里,并轻松地进行获取该分支的最新提交。或者只是让git子模块追踪标签(也许?)。
我在技术上说,如果告诉子模块跟踪分支,我可以省略 - 远离git submodule update命令来获得特定的提交(如果我是,在子模块文件夹中检出一个提交/标记,并将更改提交给超级回购),并获取特定标记,稍后添加 - 远离另一个git子模块更新,最终在与该提交有关的分支中,有点解决整个问题?
。
然后,只需确保您的子模块正在跟踪释放分支,从可以的位置开始选择创建你自己的,并添加更多的提交。记住,即使在一个分支之后,一个git子模块更新 - 使用 git获取
并更新子模块,但始终将其保留在中。
请参阅。
由您决定要在哪个分支上工作。
如果您已经在使用您自己在该子模块中的专用分支,使用以更新它:
git submodule update --remote --rebase
这会将您当前的工作重新定位到更新的子模块之上。
I am working in a project where we use git submodules for purposes of tracking the code as whole (Several different parts which are released together) so I like the idea that submodules tracks a specific commit since what submodules will mostly be used for are history purposes.
This is nice so that in the future one can checkout a specific tag of the super repo and find out where the code was at for each component. An issue arises though if all of a sudden you want to perform some more commits to that specific version because since you are in a headless state there is no real way to find out which branch that commits belong to.
Tracking branches, as has been added in 1.8.2, doesn't seem to solve the issue either from what I can read as that will just checkout the latest commit in a branch which may not be what was released at the time.
Is there some sort of way to mix the 2 where one can checkout the super repo and see which commit everything was at then but still be tracked to a branch so that he knows exactly which branch to pull from (As they may have been more commits to that branch) and keep commiting to it?
I guess what I am looking for is to somehow have git fall in a state as if the developer had several commits to pull down from the server where his local repo head is at the right commit but the server has moved ahead, this way he could know exactly where he is at and easily do a pull to get latest commits for that branch. Or just have git submodules track tags (maybe?).
Am I correct in saying that technically, if tell a submodule to track a branch, I can omit the --remote from "git submodule update" command to get the specific commit (If I were, to say, checkout a commit/tag while in the submodule folder and commit the changes to the super repo) and get the specific tag and later on add the --remote to yet another "git submodule update" to end up in the branch pertaining to that commit, somewhat solving the whole issue?
Any input on the matter is appreciated.
Then simply make sure that your submodule is tracking a "release" branch, from where you can chose to create your own, and add more commits.
Remember that, even when following a branch, a git submodule update --remote with git fetch
and update the submodule, but always leaving it in a detached HEAD mode.
See "Git submodule to track remote branch".
It is up to you to then define the branch in which you want to work on.
If you were already working on a dedicated branch of your own within that submodule, use, to update it:
git submodule update --remote --rebase
That will rebase your current work on top of the updated submodule.
这篇关于Git子模块跟踪提交但知道分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!