Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • Best comment ever. Because the one, which is the accepted answer, assumes that the file that has to be fetched is pushed upstream, however this command fetches/restores the file which only exists locally.
    – alperc
    Commented Aug 21, 2018 at 13:21
  • 1
    Just tried this in the root folder of my local git repo. I still needed to provide the relative path to the file. Just providing the -- [filename] on it's own didn't work. Commented Dec 4, 2018 at 2:09
  • @ot0 No, it doesn’t assume that. They are exactly the same answer.
    – matt
    Commented May 30, 2020 at 16:57