<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>thr3a</author_name>
  <author_url>https://blog.hatena.ne.jp/thr3a/</author_url>
  <blog_title>動かざることバグの如し</blog_title>
  <blog_url>https://blog.turai.work/</blog_url>
  <categories>
    <anon>git</anon>
  </categories>
  <description>やりたいこと 別ブランチにある特定ファイルだけを、いまの作業ツリーへ引っ張ってきたいことがある。 git restore --source &lt;branch&gt; でも近いことはできるが、雑に叩くとインデックスや手元の変更まで意識する必要があって地味に気を使う。欲しいのは「指定ブランチから指定ファイルだけ抜き出して、必要なら既存ファイルを退避してから上書きする」くらいの単機能なやつである。 その場で毎回 git show branch:path &gt; file を組み立ててもよいが、絶対パスと相対パスの差分吸収やバックアップ作成まで含めるとシェルスクリプトにしておいた方が楽だった。 コード 以下を ~…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.turai.work%2Fentry%2F20260521%2F1779293846&quot; title=&quot;Gitで別ブランチの特定ファイルをサルベージしたい - 動かざることバグの如し&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2026-05-21 01:17:26</published>
  <title>Gitで別ブランチの特定ファイルをサルベージしたい</title>
  <type>rich</type>
  <url>https://blog.turai.work/entry/20260521/1779293846</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
