从主代码的*部分*分支,如何保持最新?
为我的问题制定标题有点困难,因为它有点抽象......
让我尝试解释一下。我有一个带有 git 存储库的主代码,我决定提取该代码的部分,并将其作为一个独立的应用程序。具有自己的名称和要分发的版本。
有没有办法保持主代码和其他分支更新?前任。如果我在 Main 上找到该代码的解决方法,如果我可以将该更改合并到独立版本(不添加任何其他功能)以及如果我在独立版本上添加新功能,我想应用它也到主代码。
目前我有一个分支,但我不确定是否会很快创建自己的 git 存储库。
我知道 git add -p ,但有时我必须进行许多更改,并且一一进行直到到达我想要应用的更改有时是一种痛苦。
任何信息将不胜感激
Was little bit difficult to formulate the title for my question since is kind of abstract...
Let me try to explain. I have a main code which has a git repository, I decided to take part of that code and make it a stand alone app. with its own name and versions to be distributed.
Is there a way to keep the main code and that other branch updated? ex. If I find a workaround for that code on Main, if I can merge that change to the stand alone (without adding any of the other functionality) as well as if I add a new feature on the stand alone, I would like to apply it to the main code as well.
Currently I have a branch but Im not sure If I will create its own git repository soon.
I am aware of git add -p
but some times i have to many changes and going 1 by 1 until I arrive to the one I want to apply is sometimes a pain.
Any info would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我相信你想要的实际上类似于部分克隆,GIT 不支持它。
要么将该“部分”放入单独的存储库并使用子模块,要么为独立应用程序创建一个分支并删除所有未使用的内容。
I believe what you want is in fact similar to a partial clone, for which is not supported in GIT.
Either put that "part" into a separate repository and make use of submodule, or create a branch for the standalone app and delete all unused stuff.
您可以使用
gitcherry-pick
获取各个提交并将它们合并到当前分支中。对于长期运行的开发来说可能有点烦人,但这是解决您的问题的一种可能的解决方案。
You can use
git cherry-pick
to grab individual commits and merge them into your current branch. Might be kind of annoying for long-running development, but it's one possible solution to your problem.最像你所描述的工具是 Git 的一个附加组件,称为 git-subtree:
http://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt
它的工作方式有点像子模块,但项目实际上并没有链接在一起,您可以根据需要提取和重新合并。关于该工具是否很快会与 Git 本身一起分发的讨论正在进行中。
The tool most like what you describe is an add-on to Git, known as git-subtree:
http://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt
It works a bit like submodules, but the projects aren't actually linked together, and you can extract and re-merge as much as you like. There are ongoing discussions regarding whether this tool will soon be distributed with Git itself.