bzr:将文件从一个分支复制到另一个不相关的分支

发布于 2024-09-15 05:43:08 字数 45 浏览 2 评论 0原文

是否可以将文件从一个分支复制到另一个不相关的分支,同时保留该文件的历史记录?

Is it possible to copy a file from one branch to another unrelated branch while preserving history for that file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骷髅 2024-09-22 05:43:08

Bazaar 没有直接支持此操作。

尽管您可以使用其他工具来实现此目标。但这不是一个非常简单的操作。您可以使用 bzr-fasimport 插件将分支的完整历史记录导出到 fastimport 流中,然后过滤所需文件的历史记录并仅使用此文件及其历史记录创建新分支:

bzr fast-export > full-branch.fi
bzr fast-import-filter -i foo.txt full-branch.fi > only-foo.fi
bzr fast-import only-foo.fi foo-only-branch

然后将 foo-only-branch 合并到目标分支中

bzr merge /path/to/foo-only-branch -r0..-1

注意:在快速导出/快速导入舞蹈之后,only-foo的历史记录将与原始分支不兼容,因此您不能多次执行此技巧。

Bazaar has no direct support for this operation.

Though you can achieve this goal with additional tools. But it's not very trivial operation. You can use bzr-fasimport plugin to export full history of your branch into fastimport stream, then filter history for required file and create new branch with only this one file and its history:

bzr fast-export > full-branch.fi
bzr fast-import-filter -i foo.txt full-branch.fi > only-foo.fi
bzr fast-import only-foo.fi foo-only-branch

Then merge foo-only-branch into your destination branch

bzr merge /path/to/foo-only-branch -r0..-1

NOTE: after fast-export/fast-import dance the history of only-foo will be incompatible with original branch, so you can't do this trick several times.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文