Git 提交显示在错误的分支

Git commit showing in wrong branch

我在 Git 到 Visual Studio 工作,我注意到 branch-a 上存在一些提交,但出现在我的主分支的历史。 branch-a 从未合并到 master 中,我确保我拥有最新的代码,所以这是意外行为。

提交存在于 Visual Studio 线上的 master 上,但不通过 VS 的团队资源管理器。当我 运行 git log (在命令提示符中)为 master 时,我看到了提交,当我 运行 git branch --merged master.

最后一个奇怪的证据:我手动搜索代码以查找这些提交中所做的更改,但没有看到任何痕迹。我在 Visual Studio 网上搜索了我的本地代码和代码。

任何人都可以向我解释为什么会发生这种情况吗?

非常感谢!

编辑: 这是
的结果 git log --graph --decorate --oneline --boundary master...branch-a

* dcb976b (HEAD, branch-a) Refactoring export method for CA Sick Hours Repor
* dba6163 Added functional query to CA Sick Hours Report
* 705d108 Adding CA Sick Hours Report under the reports dropdown. Placeholder va
| *   95d2ac0 (origin/remote-checks-create-folder-on-project-save, origin/master
| |\
| | * cbf1dc7 (origin/project-payrun-list-report, project-payrun-list-report) Ad
| | * 7bfd8b0 Adding Project Pay Run List report (replacing the one available on
| * |   a83b229 Merge pull request 73 from mgmt-file-additions into master
| |\ \
| | * | 9ca1710 Moving format string into a const variable
| | * | 22baa60 Editing Management File: Parent Company column is now parent-mos
| * | | 0fb1d1e Replacing Min with Max to handle case where only some cells were
| * | |   fbbe9c7 Merge pull request 72 from hf-improve-db-connection-resiliency
| |\ \ \
| | |_|/
| |/| |
| | * | 0b6d09c (origin/hf-improve-db-connection-resiliency) Refactoring some co
| | * | 7f3d625 Replacing the last SqlConnection's with ReliableSqlConnection's.
| | * | 9f1ed46 Logging retry attemtps to windows event log.
| | * | 2069f5e Adding custom transient error detection for the ADO part of the
| | * | 59550c6 Refactoring several methods to use the new ReliableSqlConnection
| | * | d14a7ba Adding ReliableSqlConnection to JFA.DL.
| | * | f53c2bd Removing manual transactions (EF).
| | * | a2184e4 Adding resiliency execution strategy.
| * | |   2a2cbc2 Merge pull request 70 from hf-p-and-w-custom-report into maste
| |\ \ \
| | |_|/
| |/| |
| | * | 7665d98 (origin/hf-p-and-w-custom-report) Fixing several issues with the
| | * | c5d5605 Adding logic to gather P&W Cost Report data.
| | * | 2a631d4 half-baked EOR report changes from call with Carlos
| | * | 2cb9440 Adding method to generate P&W Costs Report content.
| | * | 03040f5 Adding code to print P&W Costs Report.
| | * | 85c76ee Adding P&W custom report.
| * | | 2d1b2b8 (tag: v1.9.4) Adding flat amount timesheet items to the sick hou
| * | | 5a4f57f (origin/hf-sick-hours-accruing-unprocessed-timesheets) Hiding "P
| * | | d3af8e5 Logging cause of application end.
| * | | 49b7ca6 Using fully processed timesheets only to calculate sick hours.
| * | | b98dc8e (origin/set-code-import, set-code-import) Fixing issue with cust
| | |/
| |/|
| * |   402e16f Merge pull request 71 from mgmt-report-add-parent-co-column into
| |\ \
|/ / /
| * | e023583 Adding parent company column to Management -> Generate Payroll Fil
| | o 0234afb Optimizing query (fringe deduction only).
o | e1afdf9 (tag: v1.9.3) Fixing issue with the ADP QTRLY File CAPs.
|/
o d383d04 (tag: v1.9.2) Fixing issue with exempt taxes.

常识表明您对代码库的看法之一已经过时。

我倾向于相信 git 命令行查询的结果(它表明 branch-a 确实已经提交到 master 中)。基于该假设,我的建议是您的 VS Team Explorer 显示的是过时的 git 状态。

根据您的团队使用的提交消息的详细信息,您也许能够看到该分支何时以及由谁合并到主分支中。这可能会让您深入了解它是如何合并的,从而避免导致错误合并的事件序列。

仔细查看提交历史后,我注意到这里实际发生的事情是这样的:

开发人员 Abranch-a 合并到开发中
[开发现在包括提交]
开发人员 B 从开发分支 branch-b
[branch-b 现在包括提交]
开发人员 Bbranch-b 合并到 master
[但仅包含来自 branch-b]
的特定项目 [master 现在包括提交,但没有 code/changes 来自提交]

所以我会相信来自命令行的历史记录/Visual Studio 在线。我假设 Team Explorer 由于错误而没有显示提交。