SourceTree显示大量变更文件但git status无此问题的解决方法
SourceTree显示大量虚假变更文件的处理方案
问题现象
- SourceTree显示仓库中有大量实际未变更的文件,但执行
git status仅能看到少量变更及未跟踪文件(具体输出见下方代码块) - 通过命令行添加并提交部分文件后,SourceTree中显示的文件数量会相应减少,但因显示文件量过大,“变更文件”子窗口一直转圈无法加载
- 已尝试移除并重新添加仓库书签,问题未解决
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: dist/sysetc/php.ini modified: dist/usrlocaltorque/web/be/CTqDatabase.php modified: dist/usrlocaltorque/web/be/dashChunker.php modified: dist/usrlocaltorque/web/js/directives/slider.js modified: dist/usrlocaltorque/web/js/directives/tqDashPlayer.js modified: dist/usrlocaltorque/web/js/pxUIHelpers.js modified: dist/usrlocaltorque/webanalytics/dash/app/lib/controlbar/ControlBar.js modified: ext/README.txt modified: lib3p64/pkgconfig/libavcodec.pc modified: lib3p64/pkgconfig/tesseract.pc modified: packaging/specs/torque-3plib.spec modified: packaging/specs/torque-branding.spec modified: packaging/specs/torque-commonapps.spec modified: packaging/specs/torque-webanalytics.spec modified: src/TqCommon/TqLogger.cpp modified: src/TqMediaProbe/TqMediaProbe.cpp modified: src/cfg/TqCfgParams.cpp modified: src/cfg/TqCfgProcessControl.cpp Untracked files: (use "git add <file>..." to include in what will be committed) dist/installers/rescue64/tqRescue64Uefi.img dist/sysetc/fonts/ ext/IntelMediaSDK-gitrepo/ ext/Simple-WebSocket-Server/ ext/ac3esbrowser/ ext/autoconf-2.71/ ext/libusb-1.0-24/ ext/libva-utils/ ext/man/ ext/tesseractOCR/ ext/zvbi/ installRemoteTorqueRsync.php lib3p64/pkgconfig/zvbi-0.2.pc src/ocr/
解决办法
1. 重置SourceTree本地缓存
SourceTree的本地缓存可能出现异常,清理后可恢复正常状态:
- 完全关闭SourceTree客户端
- 找到仓库目录下的
.git/sourcetree文件夹并删除(该目录仅存储SourceTree的本地状态,不会影响git核心数据) - 重新打开SourceTree并加载目标仓库
2. 调整git的换行符与权限检测设置
跨平台换行符差异或文件权限变更常导致SourceTree误判文件变更:
- 执行以下命令关闭自动换行符转换:
git config core.autocrlf false - 执行以下命令让git忽略文件权限变化,只检测内容变更:
git config core.filemode false
3. 刷新git索引状态
git索引异常也会导致状态不同步,执行以下命令重置索引并清理未跟踪文件:
git reset --hard HEAD git clean -fd
注意:
git clean -fd会删除所有未跟踪的文件和文件夹,执行前请确认这些文件无需保留,必要时先备份或添加到.gitignore
4. 升级SourceTree到最新版本
旧版本SourceTree存在已知的状态显示bug,升级到官方最新版本可修复此类问题。
5. 临时使用命令行完成提交操作
如果SourceTree加载卡死无法操作,可直接通过命令行完成变更提交:
# 暂存所有变更文件 git add . # 提交变更(替换为实际的提交描述) git commit -m "修复xxx功能,调整xxx配置" # 推送到远程仓库(按需执行) git push
内容的提问来源于stack exchange,提问作者Danny
相关产品推荐
相关产品推荐

