Git: checkout a single file from another commit or branch
source link: https://www.devroom.io/2011/09/13/git-checkout-a-single-file-from-another-commit-or-branch/?utm_campaign=Feed%3A+ariejan+%28ariejan%7Cdevroom.io%29
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Git: checkout a single file from another commit or branch
Posted:
2011-09-13
- Last updated:
2019-06-05
Tagged 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!
My site is free of ads and trackers. I record privacy-respecting usage statistics with Fathom.
Was this post helpful to you? Why not ☕ Buy me a coffee
Copyright © 1999-2020 Ariejan de Vroom <[email protected]>
Live now; make now always the most precious time. Now will never come again.
– Jean-Luc Picard
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK