gpt4 book ai didi

Git 图不显示分支

转载 作者:太空狗 更新时间:2023-10-29 12:52:41 25 4
gpt4 key购买 nike

为什么当我创建一个新分支并对其进行提交时,我没有在我的图表中看到它分支。

这是我正在做的代码:

git init

git add .
git commit -a

... other commits in here

git checkout -b mynewbranch

git add .
git commit -a

git checkout master
git merge mynewbranch

git add .
git commit -a

这是我在执行 git log --graph 时希望在脑海中看到的内容

* 47926e1 This is a commit back on master
\
* f3dc827 How come i am not seeing a branch in my tree
* 1cd3018 This should be on my new branch
/
* 47f3716 This is my third commit
* 878b018 This is my second commit
* 2db9f83 Initial commit

但我看到了这个:

* 47926e1 This is a commit back on master
* f3dc827 How come i am not seeing a branch in my tree
* 1cd3018 This should be on my new branch
* 47f3716 This is my third commit
* 878b018 This is my second commit
* 2db9f83 Initial commit

我是不是没看懂什么?

最佳答案

如果您在 mynewbranch 上工作时没有要掌握的提交,您的历史记录将与您所显示的一样。在那种情况下,不需要实际 merge ; merged master 与 mynewbranch 的提示相同。如果是这种情况,git 将(默认情况下)执行所谓的快进 merge ; master 的分支指针刚刚更新为与 merge 提示相同的提交。这通常会导致更简单的提交历史记录,更易于使用,尤其是当工作也在远程存储库中进行时。

如果你想强制将 merge 记录为 git 中的 merge ,你可以在 git merge 上使用 --no-ff 选项。

在 git 中,通常认为尽可能避免 merge 是一种好的做法。

关于Git 图不显示分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16217363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com