From 26b32c1f1d20750ef9a49783882d688611b5e19d Mon Sep 17 00:00:00 2001 From: MemRelay Date: Thu, 15 Oct 2026 10:56:43 +0800 Subject: [PATCH] =?UTF-8?q?create:=20=E7=A7=BB=E5=87=BA=E8=A2=AB=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E6=96=87=E4=BB=B6=E5=90=8E=E5=88=87=E5=88=86=E6=94=AF?= =?UTF-8?q?=E4=BC=9A=E5=88=A0=E6=9C=AC=E5=9C=B0=E5=89=AF=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MemRelay-Operation: memory-save:experience-git-ignored-untrack-checkout-20261015 MemRelay-Resource: 0f2a5dc2-1fe4-408f-a316-38a857431209 --- .../移出被忽略文件后切分支会删本地副本.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/移出被忽略文件后切分支会删本地副本.md diff --git a/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/移出被忽略文件后切分支会删本地副本.md b/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/移出被忽略文件后切分支会删本地副本.md new file mode 100644 index 0000000..f9ca123 --- /dev/null +++ b/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/移出被忽略文件后切分支会删本地副本.md @@ -0,0 +1,29 @@ +--- +title: 移出被忽略文件后切分支会删本地副本 +type: experience +permalink: main/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/移出被忽略文件后切分支会删本地副本 +stable_id: 0f2a5dc2-1fe4-408f-a316-38a857431209 +scope: project +memory_type: experience +project_id: 8e229c96-a83b-4a02-ac40-10a0a9da444e +usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998 +status: active +revision: 1 +request_id: experience-git-ignored-untrack-checkout-20261015 +created_at: '2026-10-15T02:56:40.591643+00:00' +updated_at: '2026-10-15T02:56:40.591643+00:00' +tags: +- git +- cleanup +- qgis +--- + +问题:把 aidocs/ 两份文件用 git rm --cached 移出版本库后,再 checkout 旧的 main(旧提交仍跟踪它们)并快进,Git 把被忽略的本地文件当成可丢弃:先覆盖成旧版,快进到删除提交时又从磁盘删掉。 +修复:git restore --source=<仍含该文件的提交> --worktree -- <路径>,再用 git hash-object 对比 blob。 +以后:移出被忽略的已跟踪文件时,不要切到仍跟踪它们的提交;或者先复制一份,或者用 git branch -f / git push origin <分支>:main 移动分支而不是 checkout。 + +另:git rm 暂存的删除会被下一次 git commit 一起带走。分批提交时,先提交前一批,再 git rm,或用 git commit -- <路径>。 + +另:本机可用 D:\WorkSpace\OSGeo4W\bin\python-qgis.bat 跑 PyQGIS 脚本验证生成的 GIS.qgz(启动约 2–3 分钟)。C:\OSGeo4W 只剩 var,不是安装目录。 + +另:曾经 tmp/aoi-market-20260910/node_modules 是指向 C:\Users\Administrator\.cache\codex-runtimes\...\node_modules 的目录链接。递归删除前先用 os.path.isjunction 找出并 os.rmdir 拆链接,确认目标条目数不变后再 rmtree。 \ No newline at end of file