English 中文(简体)
如何从另一个子文件夹合并 git 子文件夹?
原标题:How to merge a git sub folder from another sub folder?
  • 时间:2012-05-22 06:18:57
  •  标签:
  • git

这是我们的 Git 文件夹 。

<强度%xxxx/a/b/c/c

< 强度 > folder2/yyyy/a/b/c/c

过去,我们可以使用 SVN 将 文件夹1/XXX 文件夹2/yyy 合并。

在吉特也能做同样的事吗?

问题回答

最简单的解决方案是将两个目录设置为子模块/子树( 它们已经有一些不同的历史/ svn 仓库, 对不对? ) 。 然后您在文件夹1 仓库中添加一个远程, 指向文件夹2 仓库, 然后将更改合并为其他远程 :

# go to folder1 repository
cd /path/to/folder1repo
# or `cd folder1` if you are familiar with inline submodule editing caveats
# add a remote pointing to folder2 repo
git remote add folder2 /path/to/repo/folder2
# fetch it
git fetch folder2
# merge folder2 into folder1
git merge folder2/master

唯一的警告是,你实际上有一个子模块,每次你合并这些文件夹时,你都必须承诺执行超级项目(因为,例如,文件夹1将改变,超级项目必须指向不同的承诺):

cd /path/to/superproject
git add folder1
git commit -m "Merged folder2 submodule into folder1"

作为子模块的替代, 您可以使用两个焊接器的子树合并, 设置会更加复杂一点, 但随后您只需拉动来更新所有这些子树 :)

Here is a nice subtree tutorial: http://nuclearsquid.com/writings/subtree-merging-and-you/

BTW. 您可以创建一个远程到完全不同的工程, 您可以使用简单的合并 : git 使用情景是无限的 :)





相关问题
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 ...

热门标签