diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2020-08-31 09:57:58 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-08-31 21:47:45 +0300 |
commit | b214ab5aa597e748c228e657d4eb7c18960e6a67 (patch) | |
tree | 3ddaf52516ed4595071c495d049c8ee5c6a192ea /Documentation/git-worktree.txt | |
parent | bdd1f3e4da716012a52194cdfbc9c80dfdce87d4 (diff) |
worktree: teach "repair" to fix outgoing links to worktrees
The .git/worktrees/<id>/gitdir file points at the location of a linked
worktree's .git file. Its content must be of the form
/path/to/worktree/.git (from which the location of the worktree itself
can be derived by stripping the "/.git" suffix). If the gitdir file is
deleted or becomes corrupted or outdated, then Git will be unable to
find the linked worktree. An easy way for the gitdir file to become
outdated is for the user to move the worktree manually (without using
"git worktree move"). Although it is possible to manually update the
gitdir file to reflect the new linked worktree location, doing so
requires a level of knowledge about worktree internals beyond what a
user should be expected to know offhand.
Therefore, teach "git worktree repair" how to repair broken or outdated
.git/worktrees/<id>/gitdir files automatically. (For this to work, the
command must either be invoked from within the worktree whose gitdir
file requires repair, or from within the main or any linked worktree by
providing the path of the broken worktree as an argument to "git
worktree repair".)
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-worktree.txt')
-rw-r--r-- | Documentation/git-worktree.txt | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index 34fe47cecd..f70cda4b36 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -15,7 +15,7 @@ SYNOPSIS 'git worktree move' <worktree> <new-path> 'git worktree prune' [-n] [-v] [--expire <expire>] 'git worktree remove' [-f] <worktree> -'git worktree repair' +'git worktree repair' [<path>...] 'git worktree unlock' <worktree> DESCRIPTION @@ -114,7 +114,7 @@ and no modification in tracked files) can be removed. Unclean working trees or ones with submodules can be removed with `--force`. The main working tree cannot be removed. -repair:: +repair [<path>...]:: Repair working tree administrative files, if possible, if they have become corrupted or outdated due to external factors. @@ -123,6 +123,13 @@ For instance, if the main working tree (or bare repository) is moved, linked working trees will be unable to locate it. Running `repair` in the main working tree will reestablish the connection from linked working trees back to the main working tree. ++ +Similarly, if a linked working tree is moved without using `git worktree +move`, the main working tree (or bare repository) will be unable to +locate it. Running `repair` within the recently-moved working tree will +reestablish the connection. If multiple linked working trees are moved, +running `repair` from any working tree with each tree's new `<path>` as +an argument, will reestablish the connection to all the specified paths. unlock:: @@ -317,7 +324,8 @@ in the entry's directory. For example, if a linked working tree is moved to `/newpath/test-next` and its `.git` file points to `/path/main/.git/worktrees/test-next`, then update `/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next` -instead. +instead. Better yet, run `git worktree repair` to reestablish the connection +automatically. To prevent a `$GIT_DIR/worktrees` entry from being pruned (which can be useful in some situations, such as when the |