2012-11-12 79 views
6

在我的倉庫中,我有一個主分支,然後是一個從主分支出來的臨時分支。現在我需要添加第三個分支,這個分支應該來自分支分支。這意味着我需要一個分支從另一個分支出來。任何人都可以幫忙嗎?在git中的分支內創建分支

我用於創建分支的語法是這樣的:

git branch <name_of_your_new_branch> 

git push origin <name_of_your_new_branch> 

git checkout <name_of_your_new_branch> 

回答

6

這可以在本地創建分支:

git checkout staging 
git checkout -b newBranch 

,或者一個行:

git checkout -b newBranch staging 

這會從當前的頭部staging開始,但請注意,一個分支不是真的來自另一個分支:它來從提交(並且該提交可以是多個分支的一部分)。

然後,您可以把你的新分支,tracking the the remote branch在一個命令:

git push -u origin newBranch