2016-07-26 132 views
0

我試圖在GIT中創建功能分支。 我試圖創建git分支對我來說非常混亂(創建新的分支,功能)

A -- B -- C ------ D 
     \ 
     E -- 

其中第一行是怎樣的發展,第二行是特性分支。

我如何創建功能分支?喜歡這個?

git checkout -d myFeature 

修改文件後:

git add . 
git commit -m "My awesome commit" 

,然後按

git push origin myFeature 

合併在Dev分支

git merge myFeature 

,然後提交,並再次推。這是一個正確的方式嗎?
可以通過提交創建分支嗎?
什麼是GIT中的--track標誌,何時需要使用它?
分支和起源/分支有什麼區別?

有人可以解釋我關於分支?

+1

你需要一個很好的教程。有很多*糟糕的教程,你可能從其中的一些中學到了一些不真實的東西。對於一個好的教程,您可以從Pro Git書籍開始:https://git-scm.com/book/en/v2 – torek

+0

*請*閱讀那本書 - 當您有機會時。儘管在某些部分有點沉重,但不像一些初學者可能會喜歡的那樣牽手。這是[一個很好的**免費**互動課程](https://www.udacity.com/course/how-to-use-git-and-github-ud775)。 –

回答

1

我該如何創建功能分支?

如果你想在你貼出的問題創造myFeature分支從提交哈希B

git checkout -b myFeature B 

注意語法錯誤在Dev分支error: unknown switch 'd'

合併

別忘了結帳的dev分支第一,然後合併myFeature

git checkout dev 
git merge myFeature 

,然後提交,並再次推。這是一個正確的方式嗎?

無需再次提交,成功的合併將創建提交。

是否可以通過提交創建分支?

是的,這表現在步驟1

什麼意思--track標誌GIT,當我需要使用它?

我會向您推薦the git branch documentation

-t, --track 
    When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration 
    entries to mark the start-point branch as "upstream" from the new branch. This configuration will 
    tell git to show the relationship between the two branches in git status and git branch -v. 
    Furthermore, it directs git pull without arguments to pull from the upstream when the new branch 
    is checked out. 

    This behavior is the default when the start point is a remote-tracking branch. Set the 
    branch.autoSetupMerge configuration variable to false if you want git checkout and git branch to 
    always behave as if --no-track were given. Set it to always if you want this behavior when the 
    start-point is either a local or remote-tracking branch. 

是什麼分支,起源/分支之間的區別?

branch應該是指您的本地副本,並origin/branch指的是遠程服務器上的副本。

有人可以解釋我關於分支嗎?

這近乎題外話了這麼過於寬泛,但這裏的a wonderful free interactive tutorial應該除了git book和上述git branch documentation回答這個給你。