git过滤器分支和git子树之间的区别? [英] Difference between git filter branch and git subtree?

查看:239
本文介绍了git过滤器分支和git子树之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在搜索扔SO这个答案。遇到这个旧的线程似乎没有给出任何答案。重新启动这个线程希望有人知道!

有人能告诉我b / w git子树和git filter-branch的区别吗?
我会在原始问题中使用同样的例子:

  git subtree split --prefix = some_subdir -b some_branch 

git filter-branch --subdirectory-filter some_subdir some_branch


解决方案

是, git subtree (一个contrib外壳程序)可用于分割回购库,如通过。 com / stucampbellrel =nofollow noreferrer> Stu Campbell



您需要删除您在分割文件夹中复制的代码:

  git subtree split --prefix = path / to / code -b split 
git push〜/ shared / s plit:master
git rm -r path / to / code
git commit -am删除拆分代码。

git filter-branch (原生Git命令),它重写回购历史记录,实际上会影响特定子目录的内容。



含义:在 git rm c $ c> filter-branch 已经运行。

git filter-branch 不会像 git subtree split 确实:删除(过滤掉)与特定条件不匹配的所有内容(这里是子文件夹路径)

Was searching throw SO for an answer to this. Came across this older thread which didn't seem to give any answers. Retriggering this thread hoping someone may know!

Can someone tell me the difference b/w git subtree and git filter-branch? I'll use the same example in the original question for this:

git subtree split --prefix=some_subdir -b some_branch

git filter-branch --subdirectory-filter some_subdir some_branch

解决方案

Yes, git subtree (a contrib shell) can be used to split repos, as described in "Using Git subtrees for repository separation" by Stu Campbell.

You need to remove the code that you have duplicated in your split folder though:

git subtree split --prefix=path/to/code -b split
git push ~/shared/ split:master
git rm -r path/to/code
git commit -am "Remove split code."

That differs from git filter-branch (a native Git command) which rewrites the repo history picking up only those commits that actually affect the content of a specific subdirectory.

Meaning: there is no code to git rm once the filter-branch has been run.
git filter-branch does not duplicate commits like git subtree split does: it deletes ("filters out") everything that does not match a certain criteria (here a subfolder path)

这篇关于git过滤器分支和git子树之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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