<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Git Graph · 仁才德</title>
    <link>https://jared.lynskey.co.nz/zh-cn/tags/git-graph/</link>
    <description>关于软件工程与研发团队领导力的短文——绩效评估、招聘与团队扩张、CI/CD、DevOps 监控、智能体 AI。写于首尔。</description>
    <generator>Hugo</generator>
    <language>zh-CN</language>
    <copyright>© 2026 仁才德</copyright>
    <lastBuildDate>Wed, 28 Oct 2026 00:00:00 +1300</lastBuildDate>
    <atom:link href="https://jared.lynskey.co.nz/zh-cn/tags/git-graph/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>终端和VS Code里查看Git分支图：用它追进度，不搞微观管理</title>
      <link>https://jared.lynskey.co.nz/zh-cn/posts/2023/2023-06-02-project-progress-git-graph/</link>
      <guid isPermaLink="true">https://jared.lynskey.co.nz/zh-cn/posts/2023/2023-06-02-project-progress-git-graph/</guid>
      <pubDate>Fri, 02 Jun 2023 11:30:03 +0000</pubDate>
      <dc:creator>Jared Lynskey</dc:creator>
      <category>Git</category>
      <category>Git Graph</category>
      <category>VS Code</category>
      <category>Project Management</category>
      <category>Engineering Manager</category>
      <description>git log --graph命令怎么用、怎么设成别名、怎么对比两个分支，VS Code里的Git Graph插件和自带的提交图。再说说我怎么用它掌握进度，又不盯人。</description>
      <content:encoded><![CDATA[<p>想看Git分支图，最快的办法是在终端里运行<code>git log --graph --oneline --all --decorate</code>：所有分支都会画成字符线条，一行一个提交，分支名和标签名标在它们指向的提交旁边。在VS Code里，可以直接用源代码管理视图里自带的Source Control Graph，也可以装Git Graph插件，得到一张更大、能点击的图。两种方法在文末都有详细说明。</p>
<p>没人喜欢被问&quot;进展怎么样了？&quot;。可作为在公司带项目的人，我又不能不知道进展。我的折中办法是Git提交图：先看图，再决定要不要问人。大多数时候，答案已经在图里了。提交活动、分支、合并一眼可见，谁也不用为此开会。</p>

<h3 class="relative group">从图里到底能看出什么
    <div id="从图里到底能看出什么" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e4%bb%8e%e5%9b%be%e9%87%8c%e5%88%b0%e5%ba%95%e8%83%bd%e7%9c%8b%e5%87%ba%e4%bb%80%e4%b9%88" aria-label="锚点">#</a>
    </span>
    
</h3>
<p><figure><span class="mc-img" style="--lqip:url('data:image/webp;base64,UklGRqoAAABXRUJQVlA4IJ4AAAAQBgCdASogABgAPw1yrE0mIyIhKAqoxiGJ5QC3uywCxQFpuHEPXSkTd6B0z2RWZa4T7Y8RfsruOsAA/vd8+2CpyheBOdEz3RjVNYlC9RtFoqjOvb/UUWB572vAmnOtzv/AnG5mtp9GYAzXQce5Jk69dXACVLuYiXixGTwngnNtwm/gJSEGWEDi7N2CT1vDSW68w98W/Qmb3QPw7xAAAA==')"><img
    class="my-0 rounded-md"
    loading="lazy"
    decoding="async"
    fetchpriority="auto"
    alt="Git Graphs"
    width="2560"
    height="1920"
    src="https://jared.lynskey.co.nz/img/posts/gitgraphs/image_hu_4be8d7d2144dd617.webp"
    srcset="https://jared.lynskey.co.nz/img/posts/gitgraphs/image_hu_4be8d7d2144dd617.webp 800w, https://jared.lynskey.co.nz/img/posts/gitgraphs/image_hu_b6056380eece4a86.webp 1280w"
    sizes="(min-width: 768px) 50vw, 65vw"
    data-zoom-src="https://jared.lynskey.co.nz/img/posts/gitgraphs/image_hu_1c52b3c34db54258.webp"></span></figure>
</p>
<p>如果你没仔细看过：图上每个节点是一次提交，每条岔开的线是一个分支，整张图就是项目的时间线。这个布局里的信息量出乎意料地大：</p>
<ul>
<li>扫一眼就知道有几个活跃分支、提交频率如何。</li>
<li>突然安静下来的分支，或者几个星期没合并的分支，多半是有人卡住了。这种预警很值钱。</li>
<li>合并频率反映团队的协作方式。合并勤快，说明工作在持续集成；分支活得太久，往往意味着有人在孤军奋战。</li>
</ul>

<h3 class="relative group">打扰更少，对话更好
    <div id="打扰更少对话更好" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e6%89%93%e6%89%b0%e6%9b%b4%e5%b0%91%e5%af%b9%e8%af%9d%e6%9b%b4%e5%a5%bd" aria-label="锚点">#</a>
    </span>
    
</h3>
<p>明面上的好处是：不打断任何人也能掌握进度。更大的好处在真需要谈的时候：谈话从图出发，而不是从猜测出发。&ldquo;这个分支从周二就没动过，有什么卡住了吗？&ldquo;比&quot;有什么进展吗？&ldquo;强太多了。</p>
<p>把节奏挑明也有帮助。我的习惯是大多数早上扫一眼，每周认真看一次。团队知道这个节奏，所以谁也不会觉得突然。</p>

<h3 class="relative group">别把它变成监控
    <div id="别把它变成监控" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%88%ab%e6%8a%8a%e5%ae%83%e5%8f%98%e6%88%90%e7%9b%91%e6%8e%a7" aria-label="锚点">#</a>
    </span>
    
</h3>
<p>这一条我得反复提醒自己。提交数不等于价值——一次深思熟虑的提交可能顶五十次刷存在感的提交。能看到每次提交，不代表有资格质疑每个决定；要信任团队，只在模式真正不对劲时才介入。而且把图带进谈话时，它是反馈的起点，不是起诉的证据。</p>

<h3 class="relative group">在终端里看图
    <div id="在终端里看图" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%9c%a8%e7%bb%88%e7%ab%af%e9%87%8c%e7%9c%8b%e5%9b%be" aria-label="锚点">#</a>
    </span>
    
</h3>
<p>只要装了Git就行：</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git log --graph --oneline --all --decorate</span></span></code></pre></div></div>
<p>各个参数的作用：</p>
<ul>
<li><code>--graph</code>：在左侧画出分支和合并的线。</li>
<li><code>--oneline</code>：每个提交只占一行，显示短哈希和提交信息的第一行。</li>
<li><code>--all</code>：显示所有分支和标签，包括远程分支，而不只是当前所在的分支。</li>
<li><code>--decorate</code>：把分支名和标签名标在它们指向的提交旁边。新版Git在输出到终端时默认就会显示，但加上这个参数，用管道传给别的命令时名字也不会丢。</li>
</ul>
<p>每天早上敲一遍这么长的命令太累，设个别名：</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git config --global alias.graph <span class="s2">&#34;log --graph --oneline --all --decorate&#34;</span>
</span></span><span class="line"><span class="cl">git graph</span></span></code></pre></div></div>
<p>历史长的仓库，整张图怎么滚都滚不到头。几种缩小范围的办法：</p>
<div class="highlight-wrapper"><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git graph --since<span class="o">=</span><span class="s2">&#34;2 weeks ago&#34;</span>    <span class="c1"># 只看最近两周</span>
</span></span><span class="line"><span class="cl">git graph -20                      <span class="c1"># 只看最近20个提交</span>
</span></span><span class="line"><span class="cl">git log --graph --oneline main..feature                <span class="c1"># feature有、main还没有的提交</span>
</span></span><span class="line"><span class="cl">git log --graph --oneline --left-right main...feature  <span class="c1"># 两边都显示，用 &lt; 和 &gt; 区分</span></span></span></code></pre></div></div>
<p>最后两条是对比两个分支。这里用的是普通的<code>git log</code>而不是别名，因为别名里的<code>--all</code>会把其他分支全都带回来。两个点显示<code>feature</code>有而<code>main</code>没有的提交；三个点加上<code>--left-right</code>，会把两边各自独有的提交都列出来，一眼就能看出一个长期分支已经跑偏了多远。</p>

<h3 class="relative group">在VS Code里看图
    <div id="在vs-code里看图" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%9c%a8vs-code%e9%87%8c%e7%9c%8b%e5%9b%be" aria-label="锚点">#</a>
    </span>
    
</h3>
<p>VS Code自带提交图。打开源代码管理视图（Ctrl+Shift+G），里面有一个Source Control Graph分区，这是1.93版（2024年8月）加入的。默认只跟踪当前分支和对应的远程分支，用图标题栏上的分支选择器可以加上别的分支。随手看一眼的话，这就够了。</p>
<p>想一次看全所有分支，就装mhutchie开发的Git Graph插件（在扩展视图里搜&quot;Git Graph&rdquo;）。打开方式有三种：状态栏上的Git Graph按钮、源代码管理视图顶部的Git Graph图标，或者在命令面板里运行 <em>Git Graph: View Git Graph (git log)</em> 。点一个提交可以看它改了哪些文件；先点一个提交，再按住Ctrl/Cmd点另一个，就能对比这两个提交。不过这个插件从2021年起就没有发过新版本，所以自带的提交图也值得会用。</p>
<p>如果看不到Git Graph按钮，多半是插件没找到仓库。它默认只检查你打开的那个文件夹本身，不会往子文件夹里找。直接打开仓库所在的文件夹，或者在设置里调大<code>git-graph.maxDepthOfRepoSearch</code>就行。</p>

<h3 class="relative group">其他工具
    <div id="其他工具" class="anchor"></div>
    
    <span
        class="absolute top-0 w-6 transition-opacity opacity-0 -start-6 not-prose group-hover:opacity-100 select-none">
        <a class="text-primary-300 dark:text-neutral-700 !no-underline" href="#%e5%85%b6%e4%bb%96%e5%b7%a5%e5%85%b7" aria-label="锚点">#</a>
    </span>
    
</h3>
<p>大多数Git工具都能看图。<code>gitk --all</code>是Git自带的历史浏览器。GitHub、GitLab、Bitbucket的仓库页面都有&quot;network&quot;或&quot;graph&quot;视图。桌面客户端里，SourceTree（Atlassian出的免费工具）、GitKraken、Tower，以及Windows上的TortoiseGit，也都能画提交图。</p>
<p>选哪个都行，目的只有一个：看懂进度，而不是数提交。</p>
]]></content:encoded>
      <media:content url="https://jared.lynskey.co.nz/en/posts/2023/2023-06-02-project-progress-git-graph/featured.jpeg" medium="image" type="image/jpeg" />
    </item>
  </channel>
</rss>
