简体   繁体   English

git 显示了两个主分支并合并提交

[英]git shows two master branches and merge commit of them

I committed "CRM.Auctions.Data 9.3 schemes support" and then my teammate pulled it and made his own commit "esProxy ip changed" but when we looked at the repository, we saw this picture:我提交了“CRM.Auctions.Data 9.3 方案支持”,然后我的队友将其拉出并自己提交了“esProxy ip 已更改”,但是当我们查看存储库时,我们看到了这张图片:

回购

These two branches are shown both as master.这两个分支都显示为 master。 Why did it go so?为什么go会这样?

I used GitExtensions and the other git client was VS Code embedded git client.我使用了 GitExtensions,另一个 git 客户端是 VS Code 嵌入式 git 客户端。 I guess it occurred because VSCode client doesn't support fast-forward merges?我猜这是因为 VSCode 客户端不支持快进合并?

What you see is not "two master branches", it is "master" your local master branch and "origin/master", which is the local representation of the master branch on the "origin" remote.您看到的不是“两个 master 分支”,而是“master”您的本地 master 分支和“origin/master”,这是 master 分支在“origin”远程的本地表示。 This is just because of your confusing title.这只是因为您的标题令人困惑。

And D. Ben Knoble is right, you should have used git pull --rebase to avoid auto-merge when you used pull. D. Ben Knoble 是对的,您应该使用 git pull --rebase 以避免在使用 pull 时自动合并。 From git manual:来自 git 手册:

git pull is shorthand for git fetch followed by git merge FETCH_HEAD. git pull 是 git fetch 后跟 git merge FETCH_HEAD 的简写。

You should always use:您应该始终使用:

git fetch origin

Before you pull, to see what is going to happen and do a:在你拉之前,看看会发生什么并做一个:

git pull --rebase

In case of divergence.在分歧的情况下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM