ugit
ugit copied to clipboard
Undo git commit results in fatal error when the commit to undo is the initial commit
Describe the bug
When the commit to undo is the initial commit, there is no HEAD~
, so undoing this commit results in the following error:
$ ugit
fatal: ambiguous argument 'HEAD~': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
To Reproduce
$ cd ~
$ mkdir git-repo
$ cd git-repo
$ git init
Initialized empty Git repository in ~/git-repo/.git/
$ touch README.md
$ git add README.md
$ git commit -a -m "chore: initial commit"
$ ugit
Undo your last oopsie in Git 🙈️
Press ctrl+c to exit anytime
# 1 Undo git commit
# Choose git commit
fatal: ambiguous argument 'HEAD~': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Expected behavior The commit should be undone.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
macOS
- OS: macOS 10.15
- Bash Version: 5.1.16(1)
- FZF Version: 0.30.0 (brew)
- Git Version: 2.35.1
Windows
- OS: Windows 10
- Bash Version: 4.4.23(2)
- FZF Version: 0.30.0 (2093667)
- Git Version: 2.35.1.windows.2
Additional context vscode fixed this same issue via: https://github.com/microsoft/vscode/pull/47578
@Bhupesh-V Hi, I'd like to work on this issue