簡體   English   中英

如何將分支從一個存儲庫移動到不同存儲庫的另一個分支

[英]How to move branch from one repository to another branch of different repository

我使用現有的存儲庫(命名為 repoE)創建了一個新的存儲庫(命名為 repoN),只需從分支(命名為 B22)復制代碼即可。

之后,我在 repoN 中創建了一個新分支(名為 BR01)。 現在我在 repoN 存儲庫中存在的分支(名為 BR01)中進行了一些更改。

我只想將所有這些更改放入舊存儲庫 repoE 中,而不會丟失 BR01 到 B22 的歷史記錄。

我使用 SourceTree 是因為我是 Git 新手並且不知道很多命令。

  1. 站在你想要推送的當前倉庫上
  2. 結帳您要推送的分支
  3. git remote add repoRemote https://bitbucket/repo/repo1.git
  4. git push repoRemote -- 將你當前的分支git push repoRemote你在 #3 中添加的遠程git push repoRemote

首先,您需要將目標存儲庫添加到 git 中,我們稱之為repoE (設置遠程跟蹤)

git remote set-url repoE https://github.com/USERNAME/repoE.git

然后切換到您想要推送的分支,假設您的分支名為BR01

git checkout BR01

並將此分支推送到目標存儲庫

git push repoE BR01

在 SourceTree 中,可以通過將 repoE 添加到 Repository->Add Remote 來完成,以便您可以將 repoN 中的更改推送到該 repo。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM