Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Hard reset can leave behind empty directories in the working copy #670

Copy link
Copy link
Closed
@mbohy

Description

@mbohy
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.