【问题标题】:How to move branch of one repository to the other branch of different repository [duplicate]如何将一个存储库的分支移动到不同存储库的另一个分支[重复]
【发布时间】:2021-05-11 20:56:30
【问题描述】:

我有一个名为 communication_app 的存储库,一个名为 teleApp 的分支,另一个存储库是名为 patient_interface 的分支的 communication_app_patient

我想将communication_app的代码修改推送到communication_app_patient

如何迁移这些更改?

【问题讨论】:

  • git push https://github.com/the_other_repo communication_app:communication_app_patient
  • 这能回答你的问题吗? Push commits to another branch
  • 我有两个 repo,一个是我正在工作的 repo communication_app,我想将这些更改推送到 communication_app_patient repo

标签: git


【解决方案1】:

首先将您的初始存储库克隆到新位置(例如,~/saveMe/initialRepo)。

mkdir -p ~/saveMe/initialRepo
cd ~/saveMe/initialRepo
git clone <initial repository URL>
  1. 通过创建新的本地分支结帐到新的实施分支。 (例如,go-implementation) git checkout -b go-implementation origin/go-implementation

  2. 在 Git 上创建新的存储库。

  3. 将新存储库克隆到新位置。 (例如,~/saveMe/newRepo)

mkdir -p ~/saveMe/newRepository`
cd ~/saveMe/newRepo
git clone <new repository URL>`
  1. 在新存储库 (super-awesome-project) 中为初始存储库 (awesome-project) 创建一个新远程 git remote add initial-repo &lt;path-to-cloned-initial-repository&gt;

  2. 将所有文件和目录从初始存储库 (awesome-project) go-implementation 分支拉到新存储库 (super-awesome-project) 的主分支并保留历史记录。 git pull initial-repo go-implementation --allow-unrelated-histories

  3. 删除为新存储库 (super-awesome-project) 中的初始存储库 (awesome-project) 添加的远程。 git remote rm initial-repo

  4. 添加所有更改并推送到 git。

git add .
git push origin 

从下面的文章中, https://kasunsiyambalapitiya.medium.com/move-git-branch-from-one-repository-to-another-with-preserving-history-81ed64de3a02

【讨论】:

  • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-31
相关资源
最近更新 更多