The problem is the following: how to fetch a few files from a previous commit in git?
I could get the files one by one and replace them by their old version:
git show <commit>:<path> >! path
However, I would like to know whether there is a different way of performing the same thing, possibly with git reset.
In fact, I gather that
git reset <commit> <path>
puts the old file into the index. But how can the files in the index be moved back to the working tree? Or is this a bad approach?
PS: There is a wonderful graphical explanation that makes everything clear: http://marklodato.github.com/visual-git-guide/.
To put a file from a given revision into both the index and the working tree in one step, check it out:
If you’ve already put it only into the index, using
git reset <commit> <path>, then no need to specify a commit:That is, by default,
git checkout <path>copies from index to work tree, but if provided a revision argument, it will copy from there into the index first.