2014-02-28 89 views
2

我有兩個回購倉庫,並且我已經將第二個回購倉庫添加爲遠程倉庫(origin2)。我可以將來自origin1/branch1的更改推送到origin2/any_branch嗎?將分支從我的分支推送到另一個分支的不同分支

  1. 我在原產地修改過的文件/ BRANCH1
  2. 提交更改
  3. git的遠程更新
  4. 混帳推origin2 origin2/any_branch告訴我的一切是最新的。
+0

我認爲,而不是你最後一步'git push origin2 origin1/branch1'將是正確的一步。 (我不太確定...所以在嘗試之前做好備份......) –

回答

3

使用

git push origin2 branch1:any_branch 

man git push

<refspec>... 
    Specify what destination ref to update with what source object. 
    The format of a <refspec> parameter is an optional plus +, followed 
    by the source object <src>, followed by a colon :, followed by the 
    destination ref <dst>. 
1

首先,在本地檢查origin1/branch1

% git checkout branch1 
Branch branch1 set up to track remote branch branch1 from origin. 
Switched to a new branch 'branch1' 

然後推到origin2/any_branch

% git push origin2 branch1:any_branch 
Counting objects: 3, done. 
Writing objects: 100% (3/3), 238 bytes | 0 bytes/s, done. 
Total 3 (delta 0), reused 0 (delta 0) 
To path/to/origin2 
* [new branch]  branch1 -> any_branch 

參考:

1

GitHub

若要推動本地分行的成立遙控器,你需要發行 命令:

GIT中推遠程名BRANCHNAME

這是最典型地援引爲

GIT中推原點主

如果你想給分支上推的上游側的 不同的名稱,你可以發出 命令:

混帳推遠程名LOCALBRANCHNAME:REMOTEBRANCHNAME

如果本地存儲庫的副本與您推送的 上游存儲庫(後面)不同步,您將看到一條 消息,指出「此分支不能快速轉發」。這僅僅是 意味着您必須檢索上游更改才能使 推送您的本地更改。

相關問題