git branches对我来说很混乱(创建新的分支,功能)

时间:2016-07-26 20:08:05

标签: git version-control bitbucket

我试图在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中跟踪标志以及何时需要使用它? branch和origin / branch之间有什么区别?

有人可以向我解释分支吗?

1 个答案:

答案 0 :(得分:1)

  

我如何创建功能分支?

如果您尝试从提交哈希myFeature

创建B分支
git checkout -b myFeature B

注意您发布的问题error: unknown switch 'd'

中的语法错误
  

在dev分支中合并

请勿忘记先检查dev分支 ,然后合并myFeature

git checkout dev
git merge myFeature
  

然后再次提交并推送。这是正确的方法吗?

无需再次提交,成功的合并将创建提交。

  

分支是否可以通过提交创建?

是,如第1步所示

  

什么意思 - 在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之间有什么区别?

branch应该引用您的本地副本,origin/branch引用远程服务器上的副本。

  

有人可以向我解释分支吗?

对于过于宽泛的SO来说这是偏离主题的,但除了a wonderful free interactive tutorial和前面提到的{{3}之外,这里的git book应该为你解答这个问题。 }。