devroom.io/drafts/2011-09-13-git-checkout-a-single-file-from-another-commit-or-branch.md
Ariejan de Vroom dbae98c4c0 Moar updates
2013-03-24 14:27:51 +01:00

13 lines
741 B
Markdown

---
title: "Git: checkout a single file from another commit or branch"
kind: article
slug: git-checkout-a-single-file-from-another-commit-or-branch
created_at: 2011-09-13
tags:
- git
---
I recently worked on a new feature in a separate branch. It didn't work out well, so I branched master again and tried another solution. However, I needed a specific filesI committed in the first feature branch. To avoid placing those files back in my working copy by hand, I used git to checkout the specific file from the other branch.
git checkout feature_1 -- path/to/file/iwant
This will *not* checkout the `feature_1` branch, but instead checkout the most recent version of `path/to/file/iwant` in the `feature_1` branch. Very handy indeed!