English 中文(简体)
git 将次权推向另一个主次背书
原标题:git push a sub-directory into another main repo

我有一个大型项目,有多个名录subtrees

我想push一个具体小树种的变动,这个树种是一个单独的存放地。

麻烦似乎在于,目前的<>次之四>。 我想推动的不是最初来自我想推动的存放处。 它来自不同的背书,通过 替代指南。 我发现有 go。 这只是非常相似的。

大型项目布局(important_subtree)是我所担心的事情。

~/devel/bigproject
  .git/
  some_subtree/
  other_subtree/
  important_subtree/
    abc.txt
    efg.txt   <--- new version
    hij.txt

And the important_subtree is "strongly related" to that repo:

~/devel/important
   .git/
    abc.txt
    efg.txt   <--- old version
    hij.txt

现在~/devel/bigproject/important_subtree/efg.txt已经发生变化,我希望push the important_subtree onto the repocode>~/devel/important。 因此,~/devel/important/efg.txt 也有变化。

我只设法把everything in bigproject推到important,这显然不是我所想要的。 只应推动树林的改变。

最佳回答

这不再复杂,你只能使用git滤-branch。 奉命指挥,把你不想要的子direct子 cu起来,然后推向新的边远。

git clone <ORIG_REPO_DIR> <NEW_REPO_DIR>
cd <NEW_REPO_DIR>
git filter-branch --prune-empty --subdirectory-filter <THE_SUBDIR_TO_MAKE_NEW_ROOTDIR> master
git push <MY_NEW_REMOTE_ORIGIN_URL> -f .
问题回答

我将建议git-subtree。 它增加了你想要的<条码>(git subtree di)。

git subtree split --prefix=important_subtree --branch=backport <subtree merge SHA1>^.. --onto=<imported SHA1> --rejoin
git push ~/devel/important backport:master

cher 更改<代码>bigproject 自您将<条码>进口合并为“子树”,仅采用经过修改的<条码>进口商_subtree/。 然后,当你从<代码>~/devel/important进口的物品上作出新的承诺时,就予以适用,并创设一个分支<编码>后<>>>>,以便你能够以正常方式收回。 还-rejoin 因此,如果你想在更大变化上重复这一进程,你就不必在今后使用专用身份证。

与不同部门合作,可能是一件非常trick事。

或许最容易的方式是:

  1. Clone your "important" repo once more from the server.
  2. In your "bigproject" produce patches, which contain exactly the changes you intended to push in the first place (e.g. git format-patch) (you might need to make "smaller" commits in a side branch first, if your original commits mix files that should be pushed and such files that shouldn t)
  3. In your new clone of "important" apply the patches (git am)
  4. push the new clone of "important" to its default remote master. Now the push is just a simple fast forward and should not cause trouble.




相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签