2013-03-20 9 views
30

別のブランチに存在するファイルの別のバージョンを現在のブランチにロードします。git:別のブランチから現在のブランチにファイルをチェックアウトする(ヘッドを別のブランチに切り替えないでください)

git help checkoutは言う:

DESCRIPTION 
    Updates files in the working tree to match the version in the index or 
    the specified tree. If no paths are given, git checkout will also 
    update HEAD to set the specified branch as the current branch. 

すべてのこれらのファイルをチェックアウトする方法はありますが、ない更新HEAD?電流経路を提供することによって

答えて

37

チェックアウト、.

git checkout other-branch-name -- .

この動作は、switching HEAD to another branch without checking out filesに類似しているが、単に "他方向" から。

@김民준が述べているように、コミットされていない変更はすべて上書きされます。必要に応じて最初にどこかに隠したりコミットしたりすることを忘れないでください。

+2

あなたのコミットされていない作業はすべて破棄されます。後見人では明らかだが、苦労した: '( –

関連する問題