[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: git: how to restore a deleted worktree?
From: |
Nathan Moreau |
Subject: |
Re: git: how to restore a deleted worktree? |
Date: |
Sun, 7 Jan 2018 21:15:44 +0100 |
On 4 January 2018 at 23:07, Stephen Leake
<address@hidden> wrote:
> Nathan Moreau <address@hidden> writes:
>
>> It's not clear what you did when you `deleted' the worktree. The
>> proper way to cleanup worktrees is
>> + first to remove the associated branch (emacs-26)
>
> What is the git command for this?
>
To remove a branch: git -d <branch>
(or if the branch is not merged and you want to discard your work: git
-D <branch>)
>> This is probably what you need to do to get back to a clean state in
>> your case, before going to `git worktree add....' again.
>> If you just run the prune command, git won't prune anything as the
>> branch still exists.
>
> It did delete stuff from the .git/worktrees directory, since the
> emacs-26 worktree no longer existed.
>
You should really not touch what is inside the .git directory directly
(because of the risk to mess things up).
To wrap things up, to discard a worktree you should:
- remove the branch associated to it (you can find it out using the
command `git worktree list --porcelain')
- then run `git worktree prune'
In particular, I recommand you **not** to remove the directory of the
worktree manually, and not to touch the content of .git manually
either.
On 4 January 2018 at 23:07, Stephen Leake
<address@hidden> wrote:
> Nathan Moreau <address@hidden> writes:
>
>> It's not clear what you did when you `deleted' the worktree. The
>> proper way to cleanup worktrees is
>> + first to remove the associated branch (emacs-26)
>
> What is the git command for this?
>
>> This is probably what you need to do to get back to a clean state in
>> your case, before going to `git worktree add....' again.
>> If you just run the prune command, git won't prune anything as the
>> branch still exists.
>
> It did delete stuff from the .git/worktrees directory, since the
> emacs-26 worktree no longer existed.
>
>
> --
> -- Stephe
>