Git提交显示在错误的分支中

时间:2015-07-28 14:32:48

标签: git visual-studio azure-devops

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

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

最后一个奇怪的证据:我在代码中手动搜索了这些提交中所做的更改,我看不到它们的痕迹。我在Visual Studio Online上搜索了我的本地代码和代码。

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

非常感谢!

编辑: 以下是结果 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.

2 个答案:

答案 0 :(得分:1)

常识会暗示您对代码库的一种观点已过时。

我倾向于相信git命令行查询的结果(它表明branch-a确实已经被提交到master中)。根据这个假设,我的建议是你的VS团队资源管理器显示过时的git状态。

根据您的团队使用的提交消息的详细信息,您可以查看分支何时以及由谁合并为主人。这可能会让您深入了解它的合并方式,从而避免导致错误合并的事件序列。

答案 1 :(得分:0)

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

开发人员A branch-a 合并到开发中     [开发现在包括提交]
开发人员B 从开发分支 branch-b     [ branch-b 现在包含提交]
开发人员B branch-b 合并为主人     [但仅包括 branch-b ]中的特定项目     [master现在包括提交,但没有提交代码/更改]

所以我会相信命令行/ Visual Studio Online的历史记录。我将假设团队资源管理器由于存在错误而未显示提交。