git - 使用 SourceTree 将两个 GIT 存储库 merge 为一个

标签 git join repository bitbucket atlassian-sourcetree

对于我开发的每个 Arduino 项目,我都有单独的 GIT 存储库,我使用连接到 Bitbucket 中的远程存储库的 SourceTree 来处理这些项目。

我想知道如何将这些存储库 merge 为一个并保存每个文件的历史更改。

是否可以在 SourceTree 中完成?我还没有通过命令行使用过 GIT。

最佳答案

您可以在 BitBucket 中创建一个新的 git 存储库,克隆它并将您现有的两个 bitbucket 存储库添加为 submodules 这个新的 repo 。

使用 Sourcetree(自 2012 年起及其 1.3 版本),这很容易。

https://blog.sourcetreeapp.com/files/2012/02/SourceTree_Submodules1.png

You’ll then be prompted to provide a source URL to clone the contents from, and the path within the current repository that this submodule will reside.

一旦你对这些子模块中的任何一个进行了更改,你就可以推送所有内容(子模块,还有记录 gitlinks , special entries in the index 的父 repo)

http://blog.sourcetreeapp.com/files/2012/02/SourceTree_Submodules5.png

(此屏幕截图适用于 mercurial 存储库,但对于 git 存储库同样有效)


另一种选择是 git subtree , illustrated here ,这differs from submodule .

尽管 git-subtree.sh add --prefix/url/to/repo.git master --squash 将通过压缩 vim-surround 存储库的整个历史来记录 merge 提交 merge 为一个,subtree push 仍会将 bash 的额外历史推送到您的原始子树存储库,从而保留并完善其历史。

关于git - 使用 SourceTree 将两个 GIT 存储库 merge 为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33069694/

相关文章:

sql - 使用联接删除 sybase 中的行

c# - 域建模 - 实现属性或 POCO 的接口(interface)?

c++ - 是否存在用于编辑 doxygen 评论的 "wiki"?

git - Ubuntu git pull merge 选项

c++ - 在 C++ 中从多个矩阵创建一个矩阵

php - SQL_BIG_SELECTS,优化我的查询

Git merge 冲突 - "commit"VS "rebase --continue"

wordpress - 找不到与我的 GOOGLE APP 引擎应用程序关联的任何远程存储库

git - 我应该使用 Git 分支来存储不相关的代码吗?

git - 来自 Nginx 的 502 Bad Gateway for large GitLab fork