Closed
Description
This is easiest explained with an example using the git CLI:
❯ git init
Initialized empty Git repository in /private/tmp/go-git-reset/.git/
❯ git commit --allow-empty -m "Initial commit"
[main (root-commit) 34a2ae3] Initial commit
❯ mkdir -p dir1/dir2
❯ echo 'file1' > dir1/dir2/file1
❯ tree dir1
dir1
└── dir2
└── file1
2 directories, 1 file
❯ cat dir1/dir2/file1
file1
❯ git add dir1
❯ git commit -m "Add dir1"
[main 8bc6548] Add dir1
1 file changed, 1 insertion(+)
create mode 100644 dir1/dir2/file1
❯ git status
On branch main
nothing to commit, working tree clean
❯ git reset --hard HEAD^
HEAD is now at 34a2ae3 Initial commit
❯ ls dir1
ls: dir1: No such file or directory
This all behaves as you'd expect: at the end, dir1 and everything under it is gone. If you use go-git to do the hard reset, dir1
will remain.
Metadata
Metadata
Assignees
Labels
No labels