Git以一個遠程分支爲基礎新建一個遠程分支

例如現在有兩個分支,master和develop

 

git checkout master //進入master分支

git checkout -b frommaster //以master爲源創建分支frommaster

 

 

git checkout develop //進入develop分支

git checkout -b fromdevelop //以develop爲源創建本地分支fromdevelop

 

git push origin fromdevelop //將本地fromdevelop分支作爲遠程fromdevelop分支

 

合併fromdevelop分支到develop分支上:

首先切換到develop分支,再執行: git merge fromdevelop

 

Please enter a commit message to explain why this merge is necessary.

請輸入提交消息來解釋爲什麼這種合併是必要的

git 在pull或者合併分支的時候有時會遇到這個界面。可以不管(直接下面3,4步),如果要輸入解釋的話就需要:

1.按鍵盤字母 i 進入insert模式

2.修改最上面那行黃色合併信息,可以不修改

3.按鍵盤左上角"Esc"

4.輸入":wq",注意是冒號+wq,按回車鍵即可

 

git push origin :fromdevelop   //刪除遠程fromdevelop分支

 

PS:

$ git push origin test:master         // 提交本地test分支作爲遠程的master分支

$ git push origin test:test              // 提交本地test分支作爲遠程的test分支

$ git branch -d <BranchName>      // 刪除本地分支