<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>分支管理 | 锤子前端</title><description>Now vibe coding, so learning hammer FE ?</description><link>https://channel.meo-ai.com</link><item><title>《Git Worktrees 入门指南：把分支变成平行工作空间》</title><link>https://channel.meo-ai.com/posts/678</link><guid isPermaLink="true">https://channel.meo-ai.com/posts/678</guid><pubDate>Sat, 18 Jul 2026 15:26:37 GMT</pubDate><content:encoded>&lt;span class=&quot;post-title-source&quot;&gt;《Git Worktrees 入门指南：把分支变成平行工作空间》&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;标签：&lt;a href=&quot;/search/result?q=%23Git&quot; title=&quot;#Git&quot;&gt;#Git&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23%E5%B7%A5%E4%BD%9C%E6%B5%81&quot; title=&quot;#工作流&quot;&gt;#工作流&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23AI%E8%BE%85%E5%8A%A9%E7%BC%96%E7%A8%8B&quot; title=&quot;#AI辅助编程&quot;&gt;#AI辅助编程&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7&quot; title=&quot;#开发工具&quot;&gt;#开发工具&lt;/a&gt; &lt;a href=&quot;/search/result?q=%23%E5%88%86%E6%94%AF%E7%AE%A1%E7%90%86&quot; title=&quot;#分支管理&quot;&gt;#分支管理&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;总结：&lt;br /&gt;&lt;br /&gt;Git worktrees 是一个被低估十年的功能，它将分支检出到独立目录而非项目根目录，让开发者能在同一仓库中并行处理多个任务。文章从基础命令讲起，演示了如何创建、管理和清理 worktree，特别强调了它在 AI 编码代理时代的新价值——多个智能体可在独立工作树中自主工作互不干扰，完成后合并回主仓库，无需将代码推送到云端即可实现并行开发。&lt;br /&gt;&lt;br /&gt;文章要点：&lt;br /&gt;&lt;br /&gt;1. Worktree 的本质就是&quot;检出到不同目录的分支&quot;，它共享完整提交历史，能正常推拉远程，唯一区别是文件物理位置不同&lt;br /&gt;2. 创建命令 &lt;code&gt;git worktree add ../project.worktrees/feature-name -b feature/name main&lt;/code&gt; 会在指定目录新建分支，但依赖需要重新安装（如 node_modules 不共享），且该分支在 worktree 存在时无法在别处检出&lt;br /&gt;3. 目录组织有两种风格：与主仓库平级的直接兄弟目录，或统一放在 &lt;code&gt;.worktrees&lt;/code&gt; 共享父目录下；后者更整洁，尤其适合 AI 代理批量创建工作树&lt;br /&gt;4. 合并变更既可以通过常规的 push + PR 流程，也可以在本地用 rebase 后 merge；清理时用 &lt;code&gt;git worktree remove&lt;/code&gt; 删除目录但保留分支，确认无用后再 &lt;code&gt;git branch -d&lt;/code&gt; 删除分支&lt;br /&gt;5. &lt;code&gt;git worktree list&lt;/code&gt; 能查看所有工作树状态，配合 &lt;code&gt;git config --global alias.wt worktree&lt;/code&gt; 设置别名后，整个工作流（创建、查看、移除）都能用简短的 &lt;code&gt;wt&lt;/code&gt; 命令完成&lt;br /&gt;6. 核心价值在于&quot;本地并行&quot;：AI 编码工具现在常用 worktrees 让多个代理同时修改代码，既避免了分支切换的上下文丢失，也省去了云端暂存的麻烦&lt;br /&gt;&lt;br /&gt;URL：&lt;a href=&quot;https://humanwhocodes.com/blog/2026/07/introduction-git-worktrees/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; title=&quot;https://humanwhocodes.com/blog/2026/07/introduction-git-worktrees/&quot;&gt;https://humanwhocodes.com/blog/2026/07/introduction-git-worktrees/&lt;/a&gt;&lt;a class=&quot;tgme_widget_message_link_preview&quot; href=&quot;https://humanwhocodes.com/blog/2026/07/introduction-git-worktrees&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot; title=&quot;Git worktrees let you check out multiple branches into separate directories simultaneously, making parallel local development straightforward whether you&apos;re working solo or alongside AI coding agents.&quot;&gt;
  
  &lt;div class=&quot;link_preview_site_name accent_color&quot;&gt;Human Who Codes&lt;/div&gt;
  &lt;img class=&quot;link_preview_image&quot; alt=&quot;A gentle introduction to Git worktrees - Human Who Codes&quot; src=&quot;/static/https://cdn4.telesco.pe/file/D-0BAcqkq53i_Pmo8l8PG92aVoHFFkoitIBBGuBRN1ovzjJn4tA2hIGfHcHlekN_zkF0PrdU3rbZz_aoeDROnjGaU9iEOTyamQ5puAMvnRkJbB9G2qnW4Zuuph4_Vy-jyPa_0PhwDqormMov935ufwtamE9BdTwNTHJ8Lz0oyNs5crWm_E5h8sFFaDbZ2GIWsFwys4wLv056qtKmFUP1HigI5Hnf3VeFQM1-OOergZK4ZHolSjqP6YSHf5suLp9iYsDoBskxGMkDW4RtUtWE6YovTCJ7YUqZk1pR5_XgGd_0q5J_GO6eePx780VSu7H7piO_quoNy1nLjg6H_D8eRA.jpg&quot; width=&quot;1200&quot; height=&quot;630&quot; loading=&quot;eager&quot; /&gt;
  &lt;div class=&quot;link_preview_title&quot;&gt;A gentle introduction to Git worktrees - Human Who Codes&lt;/div&gt;
  &lt;div class=&quot;link_preview_description&quot;&gt;Git worktrees let you check out multiple branches into separate directories simultaneously, making parallel local development straightforward whether you&apos;re working solo or alongside AI coding agents.&lt;/div&gt;
&lt;/a&gt;</content:encoded></item></channel></rss>