Skip to content

Instantly share code, notes, and snippets.

@thiagosf
Created June 17, 2020 14:37
Show Gist options
  • Select an option

  • Save thiagosf/cb1042dff7891c93635ae23cf966ae51 to your computer and use it in GitHub Desktop.

Select an option

Save thiagosf/cb1042dff7891c93635ae23cf966ae51 to your computer and use it in GitHub Desktop.

Revisions

  1. thiagosf created this gist Jun 17, 2020.
    20 changes: 20 additions & 0 deletions restore-git.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    List commits with file is inside

    ```bash
    git log --oneline --follow -- path/to/file
    ```

    The result looks like:

    ```
    8266b41 Removing file
    fb4d75c Another commit
    ```

    Copy, for example `8266b41`, and restore file like that:

    ```bash
    git checkout 8266b41^ -- path/to/file
    ```

    :rocket: