diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-09-18 17:58:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-09-18 17:58:04 -0700 |
commit | 45f462b5c5a55039c35fc7001f2256329220bf4f (patch) | |
tree | ebac01e4f5554e4bde0572454fbe9e85a087e5bc /Documentation | |
parent | Merge branch 'jk/add-i-fixes' (diff) | |
parent | git-worktree.txt: discuss branch-based vs. throwaway worktrees (diff) | |
download | tgif-45f462b5c5a55039c35fc7001f2256329220bf4f.tar.xz |
Merge branch 'es/wt-add-detach'
"git worktree add" learns that the "-d" is a synonym to "--detach"
option to create a new worktree without being on a branch.
* es/wt-add-detach:
git-worktree.txt: discuss branch-based vs. throwaway worktrees
worktree: teach `add` to recognize -d as shorthand for --detach
git-checkout.txt: document -d short option for --detach
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/git-checkout.txt | 1 | ||||
-rw-r--r-- | Documentation/git-worktree.txt | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 5b697eee1b..afa5c11fd3 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -198,6 +198,7 @@ Use `--no-guess` to disable this. Create the new branch's reflog; see linkgit:git-branch[1] for details. +-d:: --detach:: Rather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt index f70cda4b36..32e8440cde 100644 --- a/Documentation/git-worktree.txt +++ b/Documentation/git-worktree.txt @@ -32,6 +32,18 @@ A repository has one main working tree (if it's not a bare repository) and zero or more linked working trees. When you are done with a linked working tree, remove it with `git worktree remove`. +In its simplest form, `git worktree add <path>` automatically creates a +new branch whose name is the final component of `<path>`, which is +convenient if you plan to work on a new topic. For instance, `git +worktree add ../hotfix` creates new branch `hotfix` and checks it out at +path `../hotfix`. To instead work on an existing branch in a new working +tree, use `git worktree add <path> <branch>`. On the other hand, if you +just plan to make some experimental changes or do testing without +disturbing existing development, it is often convenient to create a +'throwaway' working tree not associated with any branch. For instance, +`git worktree add -d <path>` creates a new working tree with a detached +`HEAD` at the same commit as the current branch. + If a working tree is deleted without using `git worktree remove`, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (see @@ -164,6 +176,7 @@ To remove a locked working tree, specify `--force` twice. exists. `-B` overrides this safeguard, resetting `<new-branch>` to `<commit-ish>`. +-d:: --detach:: With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD" in linkgit:git-checkout[1]. |