Mat*_*ram 2 git branch feature-branch git-flow branching-strategy
我在git树中遇到了意外情况。我已经从master创建了一个分支,但是当我在新分支上执行提交时,好像这些提交与master在同一代码行中进行...
如您所见,在最左侧是master(深蓝色)的代码行,在顶部,我们可以看到Sprint_15,它是master的分支,似乎在同一行上有提交...不知道为什么会这样。由于功能已合并到Sprint_15中而不是母版中,因此我希望代码会换行,
我的想法是,通过将Sprint_14和Sprint_15合并在一起,这在历史上做得很时髦,但是我不确定为什么。
我对git还是很陌生,因此它的某些基础仍然让我感到困惑。
似乎您对git的工作方式有些误解(这是正常现象,因为您说自己是git的新手)
每个分支不一定都拥有自己的行。如果您的分支机构Sprint_15以它为基础,master并且之前Sprint_15有任意数量的提交,master那么它们将共享同一行。一旦master获得新的提交,我想您就会看到您的期望。
您可以像这样在单独的git repo中进行测试。
$ mkdir testing && cd testing
$ git init # should put you on master branch by default
$ touch testFile.txt
$ git add -A
$ git commit -m "initial commit"
$ git branch newBranch
$ git checkout newBranch # switch from master to newBranch
### modify the testFile.txt in some way and then...
$ git add -A
$ git commit -m "first commit on newBranch"
Run Code Online (Sandbox Code Playgroud)
现在,如果您使用相同的工具查看您的仓库,您应该只会看到一行,如下所示:

现在回到master分支并再次提交:
$ git checkout master
### make another change to testFile.txt
$ git add -A
$ git commit -m "second commit on master"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1054 次 |
| 最近记录: |