git子树:可以更改分支库中的子树分支/路径? [英] git subtree: possible to change subtree branch/path in a forked repository?

查看:132
本文介绍了git子树:可以更改分支库中的子树分支/路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在存储库 A 中,文件夹 sub 包含在存储库的 S - 指向 master 分支。



c> A 分成 F 。现在我想在 F 中执行以下操作之一:
$ b


  • 更改 sub 使用不同的分支 S (即 develop 分支)

  • 或者:更改 sub 以完全使用不同的存储库


其中之一是否可能,如果是,如何?是否有任何副作用我应该知道?



我如何确保我的子树更改不会在存储库 A 当我合并我的更改(拉请求)?我的意思是除了隔离提交。

解决方案

如果您使用 git subtree 而不是 git submodule )创建子树,那么它只是一个普通的目录。要将其切换到另一个分支,只需将其删除并从新分支中重新创建子树。这是:

  git rm< subtree> 
git commit
git subtree add --prefix =< subtree> < repository_url> <分支>

这应该没有问题。


In a repository A the folder sub is included as git subtree of the repository S - pointing to master branch.

I have forked repository A into F. Now I want to do one of the following in F:

  • change sub to use a different branch of S (ie develop branch)
  • or: change sub to use a different repository altogether

Is either one of these possible, and if so, how? Will there be any side effects I should know of?

And how can I make sure my subtree change won't be updated in repository A when I merge my changes (pull request)? I mean besides isolating commits.

解决方案

If you used git subtree (and not git submodule) to create the subtree, then it's just a normal dir. To switch it to another branch, just delete it and recreate the subtree from the new branch. This is:

git rm <subtree>
git commit
git subtree add --prefix=<subtree> <repository_url> <branch>

That should work without problems.

这篇关于git子树:可以更改分支库中的子树分支/路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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