what does worktree prune do 1

what does worktree prune do

$ mkdir a
$ cd a
$ git init
$ git commit --allow-empty --allow-empty-message -m ''
$ git worktree add ../b
$ ls .git/worktrees/
b
$ rm -rf ../b
$ git worktree prune
$ ls .git/worktrees/
$

Here is what the above code is Doing:
1. Create a new directory, initialize it as a git repository, and commit an empty commit.
2. Create a new worktree in a directory called b.
3. List the worktrees in the repository.
4. Delete the worktree directory.
5. Prune the worktree.
6. List the worktrees in the repository.

Similar Posts