jesseduffield / jesseduffield/lazygit

Easy way to checkout/reset/resotre deleted file/folders

Open
#5,080 5 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Is your feature request related to a problem? Please describe.

When a file was deleted in a past commit, lazygit shows it as D in that commit’s file list. However, pressing c (checkout/restore file) on that D entry fails because lazygit runs git checkout -- , and the path no longer exists in that commit.
To restore such a file today, I have to manually locate the parent/previous commit where the file still existed and then press c there. This is inconvenient, especially when the deletion happened long ago or involved multiple files.

### Describe the solution you'd like

Possible UX options:

- Pressing c on a D file automatically restores it from ^ (or the nearest ancestor containing the file).
- Or add a separate action like "Restore deleted file from parent commit" in the context menu / keybinding.

### Describe alternatives you've considered

Using CLI commands such as:

```sh
git checkout ^ --
git restore --source ^
```

### Additional context

This feature would be particularly useful for:

- Restoring multiple deleted files quickly.
- Deletions that happened many commits ago (hard to locate the last existing commit).
- Users who rely on lazygit to avoid dropping into the CLI.

If helpful, the underlying logic could be:

- Detect that the file is deleted in the selected commit.
- Run `git checkout ^ -- `

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.