2016-07-26 138 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回答这个给你。