You have a perfect git branch model, neatly dividing code between the release and the development or trunk branch. Now suddenly you realise that you need to use the file from the other branch. But you can’t merge the branch for that sake !! WTF !
git checkout !! help !
- Make sure the file that you want to pull is clean (ie. that file shouldn’t be shown as modified in git status)
$ git checkout <other-branch-name>/<commit-hash> -- path/to/the/file
You can now checkout the branch’s HEAD or that hash’s state of the file into your current working directory. You can now play with your file, add, commit. Done !