[Git] git checkout で異なるブランチのファイルを持ってくる

ファイル単位でマージしたい。

[markdown]
いままで意識せずに patch オプションを利用していました。

> * [How can I merge a specific file from one branch into another branch in Git – Stack Overflow](http://stackoverflow.com/questions/13711455/how-can-i-merge-a-specific-file-from-one-branch-into-another-branch-in-git)
> * [git-checkout(1)](http://ktateish.github.io/git-doc-ja_JP/Documentation/git-checkout.html)

feature ブランチのファイルと差分があります。

“`prettyprinted
% git diff –name-status feature
M bower.json
“`

`git checkout` で、現在のブランチにファイルを持ってきます。
オプションの `-p`, `–patch` は省略可能。

“`prettyprinted
% git checkout feature bower.json
“`

ファイルはステージ(git add)された状態となります。

“`prettyprinted
% git status
On branch develop
Changes to be committed:
(use “git reset HEAD …” to unstage)
modified: bower.json
“`

正確にはマージではないかもですが、よく使ってます。
[/markdown]