Git触发自动打包后分支显示无提交,排查原因与提交恢复方法
Git提交异常故障记录与待解问题
完整操作流程与提交输出
- 提交前状态核验:操作时当前工作路径位于项目
mobile子目录下,执行git add ..暂存全量变更后,通过git status确认暂存区仅包含预期的修改文件、重命名文件,状态完全符合预期。 - 提交操作执行:运行带自定义提交信息的
git commit命令后,终端返回Git后台自动优化打包的提示,同步输出了本次提交的结果信息:
Auto packing the repository in background for optimum performance.See "git help gc" for manual housekeeping. [SelectingDate 910641c4] Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly. 7 files changed, 43 insertions(+), 15 deletions(-) rename mobile/features/itemLists/CursorItemsCoordinator/{AnimatedVisibilityCursor.native.js => AnimatedTranslatingCursor.native.js} (52%)
仅从终端输出来看,本次提交已正常创建。
提交后异常表现
- 提交完成后立刻执行
git status检查状态,出现异常结果:终端提示当前所在的SelectingDate分支尚无任何提交记录,仓库内所有文件均被标记为暂存的新增文件。 - 当前工作区的文件内容为更新后的正确版本,项目根目录下的
.git目录完整保留,总大小超过100MB。本地使用的Git版本为2.24.3(Apple Git-128)。 - 执行
git reflog --all可正常读取全量历史操作记录,输出内容如下:
910641c4 (selectingDate) refs/heads/selectingDate@{0}: commit: Switching from many visibility animators to one translate animated view. Cuts down time to update list significantly. f367a4d0 (refs/stash) refs/stash@{0}: WIP on SelectingDate: 37d06850 Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed). e1437645 refs/stash@{1}: WIP on master: 193f904e Merge pull request #213 from bendelonlee/MobileGraphicCalNotes f16f4e59 refs/stash@{2}: WIP on selectingDate: 37d06850 Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed). 37d06850 refs/heads/selectingDate@{1}: commit: Ensures that restoreListener is readded to animatedDateValue when it is updated (and that any old one is removed).
待解答问题
- 这类故障的触发原因是什么
- 如何操作才能找回当前分支的所有提交记录
内容的提问来源于stack exchange,提问作者Benjamin Lee
相关产品推荐
相关产品推荐

