<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>董振业的博客</title>
        <link>https://dongzhenye.com/</link>
        <description>一名产品经理的原创成长笔记</description>
        <lastBuildDate>Thu, 08 Jan 2026 11:33:03 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>zh-CN</language>
        <copyright>All rights reserved 2026, 董振业</copyright>
        <item>
            <title><![CDATA[Cursor在Windows下终端失败：退出代码1的解决方案]]></title>
            <link>https://dongzhenye.com/article/cursor-windows-terminal-exit-code-1-solution</link>
            <guid>https://dongzhenye.com/article/cursor-windows-terminal-exit-code-1-solution</guid>
            <pubDate>Wed, 19 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[在Windows 11环境下使用Cursor IDE时，调用终端总是会失败，错误信息为
powershell.exe -i"已终止，退出代码: 1 ]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1bbef3edbf2680169ed3da0c54f7f5b5"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf2680b5bc84ff27f56c0a2f" data-id="1bbef3edbf2680b5bc84ff27f56c0a2f"><span><div id="1bbef3edbf2680b5bc84ff27f56c0a2f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680b5bc84ff27f56c0a2f" title="问题描述"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">问题描述</span></span></h3><div class="notion-text notion-block-1bbef3edbf2680c5afcfefb611e89d73">在Windows 11环境下使用Cursor IDE时，调用终端会失败，错误信息为：</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf2680f898daf90605af861d" data-id="1bbef3edbf2680f898daf90605af861d"><span><div id="1bbef3edbf2680f898daf90605af861d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680f898daf90605af861d" title="原因分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">原因分析</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1bbef3edbf268097a7b7f155e04c3f81" style="list-style-type:decimal"><li>Windows 11默认安装的是Windows PowerShell 5.1版本</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1bbef3edbf2680f5acd4ec78d7b22ac3" style="list-style-type:decimal"><li>Cursor IDE与旧版PowerShell的集成存在兼容性问题</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1bbef3edbf26807a9e18e7893b6b8804" style="list-style-type:decimal"><li>这个问题在社区中比较常见，特别是在Windows环境下</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf26802e9381e1ad02692cdf" data-id="1bbef3edbf26802e9381e1ad02692cdf"><span><div id="1bbef3edbf26802e9381e1ad02692cdf" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf26802e9381e1ad02692cdf" title="解决方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">解决方案</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1bbef3edbf26806391b4d663e84387e3" data-id="1bbef3edbf26806391b4d663e84387e3"><span><div id="1bbef3edbf26806391b4d663e84387e3" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf26806391b4d663e84387e3" title="方案1：升级PowerShell（推荐）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方案1：升级PowerShell（推荐）</span></span></h4><ol start="1" class="notion-list notion-list-numbered notion-block-1bbef3edbf2680ce9d52d320bcf655e5" style="list-style-type:decimal"><li>升级到PowerShell 7.5（最新稳定版）</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1bbef3edbf268071b4a6eb111d393962" style="list-style-type:decimal"><li>升级方法：</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf268071b4a6eb111d393962" style="list-style-type:lower-alpha"></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1bbef3edbf26806baa37dd55f16e68e0" style="list-style-type:decimal"><li>验证安装：</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf26806baa37dd55f16e68e0" style="list-style-type:lower-alpha"></ol></ol><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1bbef3edbf2680a5a3c6d7929d535b36" data-id="1bbef3edbf2680a5a3c6d7929d535b36"><span><div id="1bbef3edbf2680a5a3c6d7929d535b36" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680a5a3c6d7929d535b36" title="方案2：切换终端"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">方案2：切换终端</span></span></h4><div class="notion-text notion-block-1bbef3edbf26805b9c33eace666715e8">Cursor支持多种终端，每种都有各自的优势和适用场景：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1bbef3edbf2680428e56e78163c87487" style="list-style-type:decimal"><li>PowerShell 7.x</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf2680428e56e78163c87487" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268054baf7f4fa5c872eca"><li>优点：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268054baf7f4fa5c872eca"><li>与Windows深度集成</li><li>功能强大，支持复杂脚本</li><li>原生支持.NET生态系统</li></ul></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680249f51deffa2eb0176"><li>适用场景：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680249f51deffa2eb0176"><li>需要Windows系统管理能力</li><li>使用.NET开发</li><li>需要PowerShell特有功能</li></ul></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1bbef3edbf268078a605c0c663ce97de" style="list-style-type:decimal"><li>Git Bash</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf268078a605c0c663ce97de" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680aba108df63081d35f4"><li>优点：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680aba108df63081d35f4"><li>轻量级，启动快</li><li>提供基础Unix命令</li><li>与Git无缝集成</li></ul></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268004a28dfdff65f51db1"><li>适用场景：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268004a28dfdff65f51db1"><li>需要使用基本Unix命令</li><li>前端开发（npm/pnpm等）</li><li>需要Git命令行工具</li></ul></ul></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1bbef3edbf2680768949d8467cf84df0" style="list-style-type:decimal"><li>WSL（Windows Subsystem for Linux）</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf2680768949d8467cf84df0" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26801681e1c150e7c44259"><li>优点：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26801681e1c150e7c44259"><li>提供完整Linux环境</li><li>支持大多数Linux工具链</li><li>可安装多种Linux发行版</li></ul></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680688ddbdd13208c0611"><li>适用场景：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680688ddbdd13208c0611"><li>需要完整Linux工具链</li><li>需要Linux包管理器</li><li>需要模拟Linux生产环境</li></ul></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680179310c5a3e5c4a39c"><li>注意事项：</li><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680179310c5a3e5c4a39c"><li>建议将项目放在WSL文件系统（而不是/mnt/c/）</li><li>WSL2访问Windows文件系统可能较慢</li></ul></ul></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf2680b8bb83d7e9663fc44c" data-id="1bbef3edbf2680b8bb83d7e9663fc44c"><span><div id="1bbef3edbf2680b8bb83d7e9663fc44c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680b8bb83d7e9663fc44c" title="使用建议"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">使用建议</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1bbef3edbf268032b030d1b0f578a861" style="list-style-type:decimal"><li>根据技术栈选择</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf268032b030d1b0f578a861" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680119b2ef0d9c48e369e"><li><b>Web/JavaScript开发</b>：PowerShell 7.x或Git Bash通常足够</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26808690e1d2d5b2e2c626"><li><b>Python开发</b>：WSL提供更好的包管理和环境支持</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268066a021f18632fa5274"><li><b>.NET开发</b>：PowerShell 7.x是最佳选择</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680d3866fd4ed9efc46d6"><li><b>系统工具开发</b>：根据目标平台选择PowerShell或WSL</li></ul></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1bbef3edbf268055bb41c36250e5b375" style="list-style-type:decimal"><li>根据工作环境选择</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf268055bb41c36250e5b375" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268016acd4f0157dc7eba2"><li><b>多人协作项目</b>：尽量与团队保持一致的终端环境</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26801cbde2c5b3df18343d"><li><b>跨平台部署</b>：选择与生产环境相似的终端（通常是WSL）</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680bdbb0adba4ee6b04c2"><li><b>Windows专属服务</b>：PowerShell可能提供更好的集成</li></ul></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1bbef3edbf2680d28e8dfb37a2e56474" style="list-style-type:decimal"><li>灵活切换策略</li><ol class="notion-list notion-list-numbered notion-block-1bbef3edbf2680d28e8dfb37a2e56474" style="list-style-type:lower-alpha"><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26809aa797c60beaab2830"><li>在Cursor中使用命令面板（Ctrl+Shift+P）快速切换终端</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26800290ebed0e60965b5e"><li>考虑为不同项目配置不同的默认终端</li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf268013bbcedf62ab785b85"><li>学习每种终端的基本命令，以便快速适应</li></ul></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf2680a5a967fce0b882d5d5" data-id="1bbef3edbf2680a5a967fce0b882d5d5"><span><div id="1bbef3edbf2680a5a967fce0b882d5d5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680a5a967fce0b882d5d5" title="参考链接"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考链接</span></span></h3><ul class="notion-list notion-list-disc notion-block-1bbef3edbf2680468b44e18097abc150"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://learn.microsoft.com/en-us/powershell/">PowerShell官方文档</a></li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26807e89f6ce47d6cb3bd1"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://cursor.sh/">Cursor IDE文档</a></li></ul><ul class="notion-list notion-list-disc notion-block-1bbef3edbf26805ca4c2e6073f144419"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://learn.microsoft.com/en-us/windows/wsl/">WSL官方文档</a></li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1bbef3edbf2680808b08f377190d20c5" data-id="1bbef3edbf2680808b08f377190d20c5"><span><div id="1bbef3edbf2680808b08f377190d20c5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1bbef3edbf2680808b08f377190d20c5" title="结语"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结语</span></span></h3><div class="notion-text notion-block-1bbef3edbf26800bab40dd3b1c776aca">无论升级PowerShell或更换Git Bash/WSL，都可以让Cursor调用终端恢复正常。
期望Cursor官方更新可以解决此问题，到时候我会提供更新。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OneDrive同步Git仓库时的跨平台行尾问题]]></title>
            <link>https://dongzhenye.com/article/onedrive-git-cross-platform-line-ending-issues</link>
            <guid>https://dongzhenye.com/article/onedrive-git-cross-platform-line-ending-issues</guid>
            <pubDate>Mon, 10 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[本文探讨了使用OneDrive同步Git仓库时遇到的跨平台行尾问题。当Windows上的代码通过OneDrive同步到macOS后，Git会显示文件被修改，但实际内容未变。文章分析了这一现象的技术原因，并提供了完整解决方案，包括添加.gitattributes文件和统一Git配置，确保跨平台协作的顺畅进行。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-1b2ef3edbf2680068b34cafed0e028b3"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680179922eaf7979647f8" data-id="1b2ef3edbf2680179922eaf7979647f8"><span><div id="1b2ef3edbf2680179922eaf7979647f8" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680179922eaf7979647f8" title="问题背景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">问题背景</span></span></h3><div class="notion-text notion-block-1b2ef3edbf268038b091d8607891e8db">在Windows上提交并同步到GitHub的代码，通过OneDrive同步到macOS后，Git状态显示多个文件被修改，但使用<code class="notion-inline-code">git diff</code>却看不到实质内容变化。这个看似简单的问题揭示了跨平台协作中的一个常见陷阱，特别是当使用OneDrive同步Git仓库时。</div><div class="notion-text notion-block-1b2ef3edbf2680ffbbc6f3585abb04e0">我的环境很简单：Windows电脑上的代码通过Git提交，文件夹被OneDrive同步；macOS设备则通过OneDrive获取最新代码。当我在macOS上打开项目，Git提示有多个文件被修改，但内容上却看不出任何差别。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf268053a8efce2cff61fd20" data-id="1b2ef3edbf268053a8efce2cff61fd20"><span><div id="1b2ef3edbf268053a8efce2cff61fd20" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf268053a8efce2cff61fd20" title="问题排查：OneDrive同步后的Git变更"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">问题排查：OneDrive同步后的Git变更</span></span></h3><div class="notion-text notion-block-1b2ef3edbf2680398e27fe87f1fbe923">检查Git状态显示有6个文件被标记为修改，但常规<code class="notion-inline-code">git diff</code>看不出区别：</div><div class="notion-text notion-block-1b2ef3edbf26800f9828ea6bd36b7b69">真正的线索来自更深入的命令：</div><div class="notion-text notion-block-1b2ef3edbf268087bbf4d06e933603c7">这揭示了两个关键问题：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680e58505f2c53630b203" style="list-style-type:decimal"><li><b>文件带有macOS扩展属性</b>：</li></ol><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf26800581acfbf51571f1e8" style="list-style-type:decimal"><li><b>行尾符号发生变化</b>：</li></ol><div class="notion-text notion-block-1b2ef3edbf2680f58492d724bf5225a2">其中<code class="notion-inline-code">^M</code>表示回车符(CR)，表明行尾从LF变成了CRLF。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680a5b024f779ccb6e76f" data-id="1b2ef3edbf2680a5b024f779ccb6e76f"><span><div id="1b2ef3edbf2680a5b024f779ccb6e76f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680a5b024f779ccb6e76f" title="跨平台Git同步的技术原因分析"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">跨平台Git同步的技术原因分析</span></span></h3><div class="notion-text notion-block-1b2ef3edbf26801298f2ca8dd86a991f">这个问题的本质是<b>跨平台文件同步中的行尾处理差异</b>：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680e68bb1cf67bfc8b9ba" style="list-style-type:decimal"><li>Windows使用CRLF(<code class="notion-inline-code">\\r\\n</code>)作为行尾，macOS/Linux使用LF(<code class="notion-inline-code">\\n</code>)</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680308818ffae4111ce67" style="list-style-type:decimal"><li>Git内部存储时默认使用LF，但检出和提交时的行为取决于配置</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1b2ef3edbf26800f9031c8d977c5e16b" style="list-style-type:decimal"><li>OneDrive同步时保留了原始文件的行尾符（Windows的CRLF）</li></ol><ol start="4" class="notion-list notion-list-numbered notion-block-1b2ef3edbf268087b141e7b04ee0fb45" style="list-style-type:decimal"><li>当文件到达macOS，Git检测到与其内部存储的版本不同，标记为修改</li></ol><div class="notion-text notion-block-1b2ef3edbf26806ebb8fe21bc9969f8b">Git在内部设计时做了一个平衡：在版本库中统一使用LF存储，但在工作目录中可以根据平台和配置转换。这种设计允许跨平台协作，但需要明确配置。</div><div class="notion-text notion-block-1b2ef3edbf2680a08034c6ae75e1c032">行尾问题特别容易被忽视，因为：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680728999ca30fe3c179d" style="list-style-type:decimal"><li>它们在大多数编辑器中不可见</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680d99f1ed1daa5562303" style="list-style-type:decimal"><li>对程序运行通常没有影响（除非是脚本等特殊情况）</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1b2ef3edbf26806e8ebff6c4ffbaef9a" style="list-style-type:decimal"><li>无法通过常规<code class="notion-inline-code">git diff</code>轻易发现</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680c49fdad160c5438547" data-id="1b2ef3edbf2680c49fdad160c5438547"><span><div id="1b2ef3edbf2680c49fdad160c5438547" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680c49fdad160c5438547" title="为什么Git没有默认解决行尾问题？"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么Git没有默认解决行尾问题？</span></span></h3><div class="notion-text notion-block-1b2ef3edbf268057b2c5f45728ead7c0">Git最初是为Linux内核开发设计的，默认采用&quot;不做假设&quot;的原则：</div><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680d3b325ecb307c4840a"><li>不自动更改文件内容</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680ecb7b7cc0d154efa57"><li>让用户明确指定如何处理不同情况</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680a2ba68d9c98a0683f4"><li>遵循&quot;显式优于隐式&quot;的设计理念</li></ul><div class="notion-text notion-block-1b2ef3edbf26803ba15ad35eab7481c6">这种设计哲学与Unix工具的传统一致，即工具应该专注于特定任务，而不是试图猜测用户意图。Git认为行尾处理是一个配置问题，而不是应该由Git自动决定的事情。</div><div class="notion-text notion-block-1b2ef3edbf268065ac87c30e1e743fdd">此外，不同项目可能有不同需求：</div><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf268048b096dcc9c4b0cc73"><li>有些项目需要保持原始行尾</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680928a69fd9faf86d11a"><li>有些需要强制使用特定行尾</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf268005a642c6230fd1a873"><li>而有些则希望根据平台自动转换</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf26809c992fcc98d7bfbb85" data-id="1b2ef3edbf26809c992fcc98d7bfbb85"><span><div id="1b2ef3edbf26809c992fcc98d7bfbb85" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf26809c992fcc98d7bfbb85" title="OneDrive与Git协作的解决方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">OneDrive与Git协作的解决方案</span></span></h3><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf2680709352c1352536ae97" data-id="1b2ef3edbf2680709352c1352536ae97"><span><div id="1b2ef3edbf2680709352c1352536ae97" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680709352c1352536ae97" title="立即修复当前问题"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">立即修复当前问题</span></span></h4><div class="notion-text notion-block-1b2ef3edbf2680bc9642ff80760b554b">如果确定没有实质性修改，可以用以下命令恢复文件状态：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf2680ee947fd630cd6c0a8b" data-id="1b2ef3edbf2680ee947fd630cd6c0a8b"><span><div id="1b2ef3edbf2680ee947fd630cd6c0a8b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680ee947fd630cd6c0a8b" title="长期预防策略"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">长期预防策略</span></span></h4><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf26803f8ec1c37b720205ab" data-id="1b2ef3edbf26803f8ec1c37b720205ab"><span><div id="1b2ef3edbf26803f8ec1c37b720205ab" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf26803f8ec1c37b720205ab" title="1. 添加.gitattributes文件（最关键）"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">1. 添加.gitattributes文件（最关键）</span></span></h4><div class="notion-text notion-block-1b2ef3edbf268039bee7d35c53e315eb">在项目根目录创建文件：</div><div class="notion-text notion-block-1b2ef3edbf2680ddba7adde05bc95352">这个文件的工作原理是告诉Git如何处理不同类型文件的行尾，并且会覆盖个人Git配置，确保团队一致性。它的优先级高于任何本地设置。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf268033a67ec71d84c27519" data-id="1b2ef3edbf268033a67ec71d84c27519"><span><div id="1b2ef3edbf268033a67ec71d84c27519" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf268033a67ec71d84c27519" title="2. 统一Git全局配置"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">2. 统一Git全局配置</span></span></h4><div class="notion-text notion-block-1b2ef3edbf26801b83fef2ca6e27bc67">在所有环境下使用一致配置：</div><div class="notion-text notion-block-1b2ef3edbf2680ae99a0c7ad6ff4c5b1">这告诉Git在提交时将CRLF转换为LF，但检出时不进行转换。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680658062fd48d498de14" data-id="1b2ef3edbf2680658062fd48d498de14"><span><div id="1b2ef3edbf2680658062fd48d498de14" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680658062fd48d498de14" title=".gitattributes vs. core.autocrlf：跨平台协作的最佳选择"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">.gitattributes vs. core.autocrlf：跨平台协作的最佳选择</span></span></h3><div class="notion-text notion-block-1b2ef3edbf26800d8925e8b19c0adb29">这两种配置方式有重要区别：</div><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf268054b51cffc23f5e6212"><li><b>没有任何设置</b>：行尾处理取决于每个开发者的个人配置，导致不一致</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680c0938ee70fba1bae74"><li><b>只设置core.autocrlf</b>：每个开发者可能有不同设置，仍有不一致风险</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680ef961ed7f37f4392f5"><li><b>使用.gitattributes</b>：强制统一规则，覆盖个人配置，确保一致性</li></ul><div class="notion-text notion-block-1b2ef3edbf268063b5bbf19f73d78876">.gitattributes的优势在于它与代码一起受版本控制，确保所有人使用相同规则，即使他们的个人Git配置不同。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680ff9c33ec9c36472a3e" data-id="1b2ef3edbf2680ff9c33ec9c36472a3e"><span><div id="1b2ef3edbf2680ff9c33ec9c36472a3e" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680ff9c33ec9c36472a3e" title="深入理解Git的行尾处理机制"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">深入理解Git的行尾处理机制</span></span></h3><div class="notion-text notion-block-1b2ef3edbf2680979425dbdb559c8de9">Git的行尾处理策略是其跨平台兼容性的核心部分，具体包括：</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf26809fb41ed95b1169765c" data-id="1b2ef3edbf26809fb41ed95b1169765c"><span><div id="1b2ef3edbf26809fb41ed95b1169765c" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf26809fb41ed95b1169765c" title="Git内部的行尾存储"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">Git内部的行尾存储</span></span></h4><div class="notion-text notion-block-1b2ef3edbf26806d9fb0ca9c70c7fc6c">Git在对象数据库中总是使用LF存储文本文件。这确保了存储的一致性，但带来了工作目录中的转换问题。</div><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf2680c89defd62e9677f3aa" data-id="1b2ef3edbf2680c89defd62e9677f3aa"><span><div id="1b2ef3edbf2680c89defd62e9677f3aa" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680c89defd62e9677f3aa" title="core.autocrlf的三种模式"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">core.autocrlf的三种模式</span></span></h4><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680fc8211f75b630330a4"><li><b>true</b>：检出时转换为CRLF，提交时转换为LF（Windows推荐）</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680158e39f647e808757e"><li><b>input</b>：检出时不转换，提交时转换为LF（Unix/Mac推荐）</li></ul><ul class="notion-list notion-list-disc notion-block-1b2ef3edbf2680afbbe3f5b977365b9f"><li><b>false</b>：不进行任何转换（不推荐，可能导致混合行尾）</li></ul><h4 class="notion-h notion-h3 notion-h-indent-1 notion-block-1b2ef3edbf2680d4bb0dd1f4ab25ff9d" data-id="1b2ef3edbf2680d4bb0dd1f4ab25ff9d"><span><div id="1b2ef3edbf2680d4bb0dd1f4ab25ff9d" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680d4bb0dd1f4ab25ff9d" title=".gitattributes的高级用法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">.gitattributes的高级用法</span></span></h4><div class="notion-text notion-block-1b2ef3edbf2680e6bebfdc1aac607c0b"><code class="notion-inline-code">.gitattributes</code>的<code class="notion-inline-code">text=auto</code>指令告诉Git自动识别文本文件并规范化行尾。它还支持更细粒度的控制：</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf26806388a3cd94991afb02" data-id="1b2ef3edbf26806388a3cd94991afb02"><span><div id="1b2ef3edbf26806388a3cd94991afb02" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf26806388a3cd94991afb02" title="知名开源项目的跨平台Git配置实践"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">知名开源项目的跨平台Git配置实践</span></span></h3><div class="notion-text notion-block-1b2ef3edbf268003b6b8d84c7b0babd5">研究一些跨平台开源项目，可以发现他们大多采用了类似策略：</div><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680f8bb7aeb903764c23d" style="list-style-type:decimal"><li><b>VS Code</b>：使用详细的<code class="notion-inline-code">.gitattributes</code>定义不同文件类型的行尾</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680928b98d2bec99276f2" style="list-style-type:decimal"><li><b>React</b>：采用<code class="notion-inline-code">text=auto eol=lf</code>确保所有文本文件使用LF</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680cdb188eeeea9c2c17f" style="list-style-type:decimal"><li><b>Node.js</b>：对shell脚本强制使用LF，对Windows批处理文件使用CRLF</li></ol><div class="notion-text notion-block-1b2ef3edbf26807ba4bbe73f766e9632">这些项目表明，对于跨平台协作，明确的行尾策略是必要的。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf2680e9bac2c5d62b0d9871" data-id="1b2ef3edbf2680e9bac2c5d62b0d9871"><span><div id="1b2ef3edbf2680e9bac2c5d62b0d9871" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf2680e9bac2c5d62b0d9871" title="结语"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">结语</span></span></h3><div class="notion-text notion-block-1b2ef3edbf2680aba30ac3657904363c">跨平台开发中的行尾问题看似微小，却能引发令人困惑的Git状态变化，尤其是当使用OneDrive同步Git仓库时。通过正确配置Git和添加<code class="notion-inline-code">.gitattributes</code>文件，我们可以避免这些问题，确保协作的顺畅。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf268003b1fed136151cd042" data-id="1b2ef3edbf268003b1fed136151cd042"><span><div id="1b2ef3edbf268003b1fed136151cd042" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf268003b1fed136151cd042" title="参考资料"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">参考资料</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-1b2ef3edbf26801187e9c623aa6d30a4" style="list-style-type:decimal"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://git-scm.com/docs/gitattributes">Git文档：gitattributes</a> - Git官方关于.gitattributes文件的详细说明</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-1b2ef3edbf2680fc9d3ce2fc280565e7" style="list-style-type:decimal"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://git-scm.com/book/zh/v2/%E8%87%AA%E5%AE%9A%E4%B9%89-Git-Git-%E5%B1%9E%E6%80%A7">Pro Git: 自定义Git - Git属性</a> - 权威Git书籍中关于Git属性的中文章节</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-1b2ef3edbf26801fa407c0cac954e526" style="list-style-type:decimal"><li><a target="_blank" rel="noopener noreferrer" class="notion-link" href="https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings">GitHub: 配置Git处理行尾</a> - GitHub官方关于行尾处理的最佳实践</li></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-1b2ef3edbf26809994e6eba3bf05b3f5" data-id="1b2ef3edbf26809994e6eba3bf05b3f5"><span><div id="1b2ef3edbf26809994e6eba3bf05b3f5" class="notion-header-anchor"></div><a class="notion-hash-link" href="#1b2ef3edbf26809994e6eba3bf05b3f5" title="技术附录：完整诊断命令"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">技术附录：完整诊断命令</span></span></h3><div class="notion-text notion-block-1b2ef3edbf268082ae3bed98384dda9e">对于需要深入排查类似问题的读者，以下是完整的诊断命令集：</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[哭闹测试：设定规则的好办法]]></title>
            <link>https://dongzhenye.com/article/the-crying-test-a-guide-for-setting-rules</link>
            <guid>https://dongzhenye.com/article/the-crying-test-a-guide-for-setting-rules</guid>
            <pubDate>Sun, 02 Feb 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[我希望尽量宠爱我的孩子，但我也希望她了解真实世界和社会的约束，以便存活下去。如何判断是否妥协？我想了一个好办法。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-192ef3edbf26809c80c9d24734f3170f"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-blank notion-block-192ef3edbf2680f6a2edfe41b4eb93b5"> </div><div class="notion-text notion-block-192ef3edbf2680f7bb8dff0fbb48aa7a">我希望尽量宠爱我的孩子，但我也希望她了解真实世界和社会的约束，以便存活下去。如何判断是否妥协？我想了一个好办法。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf268036a787d4f77c96f581" data-id="192ef3edbf268036a787d4f77c96f581"><span><div id="192ef3edbf268036a787d4f77c96f581" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf268036a787d4f77c96f581" title="场景"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">场景</span></span></h3><div class="notion-text notion-block-192ef3edbf2680f2a0a9d44f25944404">我们经常陷入这样情况：孩子做某个令我不喜欢的事情，比如踩泥坑或者摸电源插头。这些行为似乎不太好，但我不知道到底是可以妥协，还是必须严格禁止？</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680e2b069f59ee8e4ba01" data-id="192ef3edbf2680e2b069f59ee8e4ba01"><span><div id="192ef3edbf2680e2b069f59ee8e4ba01" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680e2b069f59ee8e4ba01" title="一个有趣的判断思路"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一个有趣的判断思路</span></span></h3><div class="notion-text notion-block-192ef3edbf2680d3b62fddf48e30e2ee">设想孩子跟你哭闹，你是否会向她投降？</div><ul class="notion-list notion-list-disc notion-block-192ef3edbf2680cfbb17c279ce7041c8"><li>如果最终要投降，不如现在就投降。为什么？如果哭闹有效，就会变相鼓励孩子向大人哭闹(错误的主体)，而不是学会面对真正的外部约束。</li></ul><ul class="notion-list notion-list-disc notion-block-192ef3edbf268069bfefeb1f9461f06b"><li>如果哭闹也无法妥协，那无法退让这才是原则本身的定义。</li></ul><div class="notion-text notion-block-192ef3edbf26804aae79e4668c83bf1b">我将这个简单却有效的测试叫作“<b>哭闹测试</b>”，可以帮你判断某个具体事情是否需要向孩子妥协。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680369832fdf4c80254b9" data-id="192ef3edbf2680369832fdf4c80254b9"><span><div id="192ef3edbf2680369832fdf4c80254b9" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680369832fdf4c80254b9" title="为什么"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">为什么</span></span></h3><div class="notion-text notion-block-192ef3edbf268026b3f3d0457b4a74f5">我们希望对坚持一致的原则，前后一致、言行一致，不会轻易改变。</div><div class="notion-text notion-block-192ef3edbf2680c3bc14c1430aadc3f0">我们希望在原则之上，尽可能地满足她的需求。</div><div class="notion-text notion-block-192ef3edbf268067bc77ebcf89e53dbc">就这么简单。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680fb9adae68fd085701f" data-id="192ef3edbf2680fb9adae68fd085701f"><span><div id="192ef3edbf2680fb9adae68fd085701f" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680fb9adae68fd085701f" title="一些有趣的案例"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">一些有趣的案例</span></span></h3><div class="notion-text notion-block-192ef3edbf2680a9939bdc45b3ffeba9">你可以尝试回答这些问题，来进行练习：<div class="notion-text-children"><ul class="notion-list notion-list-disc notion-block-192ef3edbf268018bf90e2b34bf0dc0a"><li>是否可以玩泥巴？</li></ul><ul class="notion-list notion-list-disc notion-block-192ef3edbf2680739cf8f00986b83a78"><li>是否可以抢小朋友的玩具？</li></ul><ul class="notion-list notion-list-disc notion-block-192ef3edbf2680c29c65d589b1aa64db"><li>是否可以摸电源插头？</li></ul></div></div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[带娃笔记：不要试图用笑来掩盖哭]]></title>
            <link>https://dongzhenye.com/article/why-laughter-cant-neutralize-tears</link>
            <guid>https://dongzhenye.com/article/why-laughter-cant-neutralize-tears</guid>
            <pubDate>Sat, 01 Feb 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[最近通过闺女观察到，人的哭与笑并不能抵消，就像糖无法冲淡盐。所以父母在小孩哭泣时不要简单粗暴地试图用逗笑来分散她的注意力，而是要分析哭的原因或诉求，帮她解决问题或满足她的需要。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-192ef3edbf26808db52bf185244ef17e"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-192ef3edbf268012b6cbe7d5e02df799"><b>经典场景</b></div><div class="notion-text notion-block-192ef3edbf26800080d1fc0bea7b4e38">在家里的客厅，一岁的闺女哭了。大人们像启动应急预案般递上塑料勺子、毛绒狗，甚至用玩具播放儿歌，花样哄她开心。孩子破涕为笑，可笑声未持续2秒，新的抽泣又涌上来。边哭编笑，像复读机的磁带循环。</div><div class="notion-text notion-block-192ef3edbf2680fca479d52f156f44c3"><b>我的观察</b></div><div class="notion-text notion-block-192ef3edbf2680d5b76ed86661a05598">我惊叹着人类幼崽可以同时哭和笑，突然意识到：情绪从不是可以相互抵消的化学试剂。成年人总爱用逗笑来覆盖哭泣，就像试图用糖去冲淡盐的咸味。哭就是哭，笑就是笑; 糖就是糖，盐就是盐。</div><div class="notion-text notion-block-192ef3edbf2680c88ea8dc2f77536be2"><b>育儿启发</b></div><div class="notion-text notion-block-192ef3edbf2680be87fce4c1f20a9519">所以我们对待孩子的哭泣，不要偷懒。停止用万能的各种逗笑来分散孩子的注意力。而是应该：</div><ol start="1" class="notion-list notion-list-numbered notion-block-192ef3edbf2680f7be5dc9e679ff5cac" style="list-style-type:decimal"><li><b>观察TA、分析TA哭的原因或诉求。</b>比如她是不是渴了、饿了、冷了、无聊了？</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-192ef3edbf2680939bfdd76b5830762e" style="list-style-type:decimal"><li><b>帮TA解决问题或满足TA的需要。</b>比如给她喝水、喂奶、穿衣服，或者出门玩一圈？</li></ol><div class="notion-text notion-block-192ef3edbf26801d8577d13de3a21881">下次，如果盐放多了，不如加点水。如果孩子哭了，记得先观察3秒钟并对TA说：&quot;爸爸/妈妈看见了。&quot;</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[带娃笔记：学会告别]]></title>
            <link>https://dongzhenye.com/article/learning-to-say-goodbye</link>
            <guid>https://dongzhenye.com/article/learning-to-say-goodbye</guid>
            <pubDate>Fri, 31 Jan 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[上午送老婆到车站，我联想到最近我与闺女告别的反复纠结。偶然想起一句之前听过但没有理解的话，突然顿悟了应该怎么做。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-192ef3edbf268069a67bcf48288ed0b0"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-192ef3edbf26800889d1f9f9c4a3375a">BGM: 柔和之光（やわらかな光） - KINGOFJ</div><div class="notion-row"><a target="_blank" rel="noopener noreferrer" class="notion-bookmark notion-block-192ef3edbf26802d91b2cd43680fe989" href="https://music.163.com/song?id=2114447605"><div><div class="notion-bookmark-title">柔和之光（やわらかな光）</div><div class="notion-bookmark-description">歌曲名《柔和之光（やわらかな光）》，由 KINGOFJ 演唱，收录于《Moonlit Night》专辑中</div><div class="notion-bookmark-link"><div class="notion-bookmark-link-icon"><img src="https://www.notion.so/image/https%3A%2F%2Fs1.music.126.net%2Fstyle%2Ffavicon.ico%3Fv20180823?table=block&amp;id=192ef3ed-bf26-802d-91b2-cd43680fe989&amp;t=192ef3ed-bf26-802d-91b2-cd43680fe989" alt="柔和之光（やわらかな光）" loading="lazy" decoding="async"/></div><div class="notion-bookmark-link-text">https://music.163.com/song?id=2114447605</div></div></div><div class="notion-bookmark-image"><img style="object-fit:cover" src="https://www.notion.so/image/http%3A%2F%2Fp1.music.126.net%2FJba7XCRsmI4w97bP_D7y2g%3D%3D%2F109951169620536848.jpg?table=block&amp;id=192ef3ed-bf26-802d-91b2-cd43680fe989&amp;t=192ef3ed-bf26-802d-91b2-cd43680fe989" alt="柔和之光（やわらかな光）" loading="lazy" decoding="async"/></div></a></div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680d2a33ef0019fe3ad21" data-id="192ef3edbf2680d2a33ef0019fe3ad21"><span><div id="192ef3edbf2680d2a33ef0019fe3ad21" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680d2a33ef0019fe3ad21" title="好好说再见"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">好好说再见</span></span></h3><div class="notion-text notion-block-192ef3edbf2680aba064f086eedb0593">在家门口的那条路上，我与爸爸妈妈爷爷奶奶挥手、鸣笛、踩下油门。第100次，他们从后视镜中消失，我去到远离家乡的地方。</div><div class="notion-text notion-block-192ef3edbf26803db4ffe03f02aa8d86">离别如此痛苦，可是我长大了。既然苦味无法避免，不如慢慢品尝。很长时间内我认为应该跟爱的人好好告别。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680359c3cc7ec58844e72" data-id="192ef3edbf2680359c3cc7ec58844e72"><span><div id="192ef3edbf2680359c3cc7ec58844e72" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680359c3cc7ec58844e72" title="悄悄告别也是一种爱"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">悄悄告别也是一种爱</span></span></h3><div class="notion-text notion-block-192ef3edbf2680868076c0fee27b027f">闺女一岁了。最近我苦恼于如何和她告别。我上班离开家时，她舍不得我。看到我穿外套或者往门口走等，就可能哼哼唧唧、打挺抗议。如果我抱着她，就用额头用力贴在我的胸口。一旦被姥姥或姥爷从我怀里抱走，立即放声大哭，在防盗门外都能听到。(作为对比，我回来时她长距离爬过来索要拥抱，不让我去卫生间洗手，一旦得逞就蹬腿表示开心)</div><div class="notion-text notion-block-192ef3edbf2680cc96e5f2f1d74d100b">为了不“戏斗”她，姥姥和妈妈都建议我，悄悄地离开家，或者至少一次搞定 (比如忘拿钥匙而让她哭两次)。我的心里挣扎了很多次、好多天。我还应坚持认真告别吗，还是偷偷溜走呢？我既不想不辞而别，也不希望她哭泣……</div><div class="notion-text notion-block-192ef3edbf268048a34dcf814371bbc1">有一天，我偶然想起一句话：</div><blockquote class="notion-quote notion-block-192ef3edbf26802e963bea4a7bae703b"><div>你走，我不送你；你来，无论多大风多大雨，我要去接你。</div></blockquote><div class="notion-text notion-block-192ef3edbf268026a32fed08f0816eea">为什么舍不得却不送一送呢？不是说应该品尝痛苦吗？</div><div class="notion-text notion-block-192ef3edbf26805493a9cafdd7d9ab4a">拖泥带水的告别，会让对方难过；可是你爱TA，你不想让TA难过。所以你放弃了自私的告别，选择让对方不告而别。原来，这是是一种为了让对方少受伤害的选择，一种无私的爱。</div><div class="notion-text notion-block-192ef3edbf2680f196d0cea0e78a5e84">我开始在上班前把东西收拾好，确保不再回头。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf2680f489bbfa16dbc41805" data-id="192ef3edbf2680f489bbfa16dbc41805"><span><div id="192ef3edbf2680f489bbfa16dbc41805" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf2680f489bbfa16dbc41805" title="最后一次告别"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">最后一次告别</span></span></h3><div class="notion-text notion-block-192ef3edbf26803d9e7ff3d4974a9764">可是，终有一天我会离开她。长亭古道边、一步三回头，如果不好好告别，我怕我走的时候会带着遗憾，在天上也遗憾。</div><div class="notion-text notion-block-192ef3edbf268059a0c8c5de3541b35e">不如我们早点开始练习？每个工作日早上，练习认真说“拜拜”; 每次远行，都认真地告诉她，我要去哪里、多久回来。我和她一起学会体面地与任何人告别，直至成为一种习惯。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-192ef3edbf26805f9cbfd0a2d4ed3bf0" data-id="192ef3edbf26805f9cbfd0a2d4ed3bf0"><span><div id="192ef3edbf26805f9cbfd0a2d4ed3bf0" class="notion-header-anchor"></div><a class="notion-hash-link" href="#192ef3edbf26805f9cbfd0a2d4ed3bf0" title="所以"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">所以</span></span></h3><div class="notion-text notion-block-192ef3edbf268088990ef3da80f15df6">为了让对方少伤心，我们离开时要坚定，不要折磨。</div><div class="notion-text notion-block-192ef3edbf268085be24cf15e12aa3e6">而为了让对方永别时不留遗憾，我们要提前练习，不要不辞而别。</div><div class="notion-text notion-block-192ef3edbf268007aa46c959a1d946f2">告别也是一种爱。</div></main></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Roam Research：如何在块内显示[[roam/js]]的结果]]></title>
            <link>https://dongzhenye.com/article/how-to-display-roam-js-results-inline-in-roam-research</link>
            <guid>https://dongzhenye.com/article/how-to-display-roam-js-results-inline-in-roam-research</guid>
            <pubDate>Sun, 05 Jan 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[下面这篇博文将分享如何在 Roam Research 中“智能”更新块的内容，以及在这个过程中所面临的种种限制与绕过技巧。文末还会简要提及在处理复杂编程需求时，运用大模型的一些优化思路。]]></description>
            <content:encoded><![CDATA[<div id="notion-article" class="mx-auto overflow-hidden "><main class="notion light-mode notion-page notion-block-172ef3edbf2680baa58ae5ddf0d33e51"><div class="notion-viewport"></div><div class="notion-collection-page-properties"></div><div class="notion-text notion-block-172ef3edbf2680c48ac7ca042111ef72">下面这篇博文将分享如何在 Roam Research 中“智能”更新块的内容，以及在这个过程中所面临的种种限制与绕过技巧。文末还会简要提及在处理复杂编程需求时，运用大模型的一些优化思路。</div><hr class="notion-hr notion-block-172ef3edbf268090a537c90c2913ef85"/><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-172ef3edbf2680ec9ea2faf1b2de473b" data-id="172ef3edbf2680ec9ea2faf1b2de473b"><span><div id="172ef3edbf2680ec9ea2faf1b2de473b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#172ef3edbf2680ec9ea2faf1b2de473b" title="在 Roam Research 中自动更新块内容：没有直接的办法"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">在 Roam Research 中自动更新块内容：没有直接的办法</span></span></h3><div class="notion-text notion-block-172ef3edbf2680f5a625edaaaf94185d">许多 Roam 用户都有类似需求：想在特定块内自动呈现某些计算结果。例如，定期汇总订阅费用、统计笔记数量、调用外部 API 等。然而，Roam 的机制决定了它并不是一个通用的 JavaScript 运行/渲染平台，有以下几个主要限制：</div><ol start="1" class="notion-list notion-list-numbered notion-block-172ef3edbf2680328930fc362a984c3a" style="list-style-type:decimal"><li>{{calc}}代码或花括号语法只支持简单数学或已有插件，不支持任意自定义JS函数。</li></ol><ol start="2" class="notion-list notion-list-numbered notion-block-172ef3edbf2680ac8e36e2da27c26405" style="list-style-type:decimal"><li>Roam 本身并不内置在块里“实时”执行脚本并渲染结果的功能。这是一个关键限制。</li></ol><ol start="3" class="notion-list notion-list-numbered notion-block-172ef3edbf2680999182fec5cc08926f" style="list-style-type:decimal"><li>需要用户自行利用 [[roam/js]] 页面编写脚本，通过手动按钮或 SmartBlocks 等插件来触发或写入块内容。但这个是手动的，无法自动更新。</li></ol><div class="notion-text notion-block-172ef3edbf2680e1a0f9c498f7c597c0">正因如此，哪怕一个看起来“只要把自定义函数结果显示在某块里”的需求，也往往需要多次摸索、调试，才能做出相对可用的实现。</div><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-172ef3edbf268068a438cc03d44a505b" data-id="172ef3edbf268068a438cc03d44a505b"><span><div id="172ef3edbf268068a438cc03d44a505b" class="notion-header-anchor"></div><a class="notion-hash-link" href="#172ef3edbf268068a438cc03d44a505b" title="常见的几种妥协解决方案"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">常见的几种妥协解决方案</span></span></h3><ol start="1" class="notion-list notion-list-numbered notion-block-172ef3edbf26801eaab0cb9e3030a144" style="list-style-type:decimal"><li><b>使用原生JavaScriptAPI更新块内容（复杂、自动）：</b></li><ol class="notion-list notion-list-numbered notion-block-172ef3edbf26801eaab0cb9e3030a144" style="list-style-type:lower-alpha"><div class="notion-text notion-block-172ef3edbf26802787f5fe0cc997b013">在 [[roam/js]] 页面中编写一段脚本，周期性（如每 10 秒）用 roamAlphaAPI.updateBlock 写一个字符串到指定块。这种方法简单粗暴，也无需单独触发，但可能占用性能，也无法在用户离开页面后停止。</div></ol></ol><ol start="2" class="notion-list notion-list-numbered notion-block-172ef3edbf2680e1a5b1e55cc233baae" style="list-style-type:decimal"><li><b>使用[[roam/render]]来渲染返回结果（简单、半自动）：</b></li><ol class="notion-list notion-list-numbered notion-block-172ef3edbf2680e1a5b1e55cc233baae" style="list-style-type:lower-alpha"><div class="notion-text notion-block-172ef3edbf2680ff9fedc85b4b36b542">在 [[roam/js]] 页面中编写一段脚本，定义一个方法来显示一段字符串。然后撰写一个代码块，引用这个脚本。最后通过[[roam/render]]渲染这个代码块，即可实现想要的效果！优点是简洁，缺点是需要手动点击。</div></ol></ol><ol start="3" class="notion-list notion-list-numbered notion-block-172ef3edbf26802595a6efde0f9ac4f0" style="list-style-type:decimal"><li><b>借助社区插件（如 SmartBlocks）（复杂、半自动）：</b></li><ol class="notion-list notion-list-numbered notion-block-172ef3edbf26802595a6efde0f9ac4f0" style="list-style-type:lower-alpha"><div class="notion-text notion-block-172ef3edbf26803e9517d74a4161ecd3">如果不排斥安装额外插件，可以让 SmartBlocks 在检测到特定触发事件时运行 JS，自动写入块。对于不熟悉脚本的用户来说，这往往是更可行的方案。</div></ol></ol><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-172ef3edbf2680df8264d6c2b104e8a7" data-id="172ef3edbf2680df8264d6c2b104e8a7"><span><div id="172ef3edbf2680df8264d6c2b104e8a7" class="notion-header-anchor"></div><a class="notion-hash-link" href="#172ef3edbf2680df8264d6c2b104e8a7" title="从需求到实现，绕过限制的关键技巧"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">从需求到实现，绕过限制的关键技巧</span></span></h3><ul class="notion-list notion-list-disc notion-block-172ef3edbf2680d59f17ed0b091631a5"><li><b>在 [[roam/js]] 下编写脚本并开启安全模式</b>
这是开放自定义代码的第一步，否则任何更新块的操作都无法执行。</li></ul><ul class="notion-list notion-list-disc notion-block-172ef3edbf26801cb632d474f0222bfd"><li><b>使用 roamAlphaAPI.updateBlock</b>
这是让脚本“写入”内容到块的关键 API，也可搭配 createBlock、deleteBlock 等实现更复杂逻辑。</li></ul><ul class="notion-list notion-list-disc notion-block-172ef3edbf268098a1fdc48ffb66854a"><li><b>合理使用 setInterval 或事件监听</b>
你可以定时检测页面状态，也能直接监听块改动。根据自身需求和技术水平选择。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-172ef3edbf26806ca56eec910a0056cd" data-id="172ef3edbf26806ca56eec910a0056cd"><span><div id="172ef3edbf26806ca56eec910a0056cd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#172ef3edbf26806ca56eec910a0056cd" title="其他体会：AI智商不足时，不要忘记升级模型"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">其他体会：AI智商不足时，不要忘记升级模型</span></span></h3><div class="notion-text notion-block-172ef3edbf26800f9b5efdd8f842a83f">如果你使用AI来协助解决问题，却反复跟大模型去调试、查不到 Roam API 文档等奇怪现象。这时除了不断优化提示词、补足上下文，也可尝试：</div><ul class="notion-list notion-list-disc notion-block-172ef3edbf2680b59fecdbb6939e5c93"><li><b>把需求尽可能明确化</b>
尤其是编程需求，要在提示词里包含你的 Roam 版本、目标 UID、输出预期、出错日志等信息，越详细越好。</li></ul><ul class="notion-list notion-list-disc notion-block-172ef3edbf2680afb3ced315c7ab07ec"><li><b>补充更多上下文或查阅GitHub、社区讨论</b>
AI 并非万能，遇到冷门或私有 API 时，你还得依赖 Roam 自己的 changelog，或者在社区里挖掘先行者的经验。</li></ul><ul class="notion-list notion-list-disc notion-block-172ef3edbf2680c0921de3c4c1a85a47"><li><b>升级到更强(更贵)的大模型</b>
例如从普通模型切换到 GPT-o1，此类模型在代码、逻辑等推理方面往往更优，大大缩短你在复杂需求上的试错成本。</li></ul><h3 class="notion-h notion-h2 notion-h-indent-0 notion-block-172ef3edbf26801eb871f4abd103e2bd" data-id="172ef3edbf26801eb871f4abd103e2bd"><span><div id="172ef3edbf26801eb871f4abd103e2bd" class="notion-header-anchor"></div><a class="notion-hash-link" href="#172ef3edbf26801eb871f4abd103e2bd" title="小结"><svg viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a><span class="notion-h-title">小结</span></span></h3><div class="notion-text notion-block-172ef3edbf268004b4ebd5c856fb63f9">要在 Roam Research 中实现“一键”或“自动化”更新块内容，说容易却并不简单。</div><div class="notion-text notion-block-172ef3edbf2680cc879fe7eb255520e5">• 你必须熟悉 Roam 的限制：原生短代码不支持自定义 JS，Roam 没有内置的实时渲染引擎。</div><div class="notion-text notion-block-172ef3edbf2680a6a8a9edccf0dc9add">• 你可以借助 roamAlphaAPI 或社区脚本（SmartBlocks 等）进行二次开发，实现在特定时间或事件触发时写入或刷新块内容。</div><div class="notion-text notion-block-172ef3edbf2680309557c19d76216ca6">• 在调试过程中，如果大模型一次性搞不定问题，也别忘了尝试升级不同模型版本、改进提示词以及搜索外部资料。</div></main></div>]]></content:encoded>
        </item>
    </channel>
</rss>