22---
33
44This wrapper script features an API for ` git-worktree ` commands
5- in order to easily create, switch and delete worktrees and branches of bare
6- repositories using widely known commands : ` git checkout ` and ` git branch ` .
5+ in order to easily create, switch and delete worktrees of bare repositories
6+ using commands you already know : ` git checkout ` and ` git branch ` .
77
88Quiet built-in checkouts are made after each overridden checkout to trigger
99post-checkout hooks.
@@ -19,7 +19,7 @@ Table of Contents
1919- [ Usage] ( #usage )
2020 - [ Clone and setup a bare repository] ( #clone-and-setup-a-bare-repository )
2121 - [ Setup fetch rules from the remote] ( #setup-fetch-rules-from-the-remote )
22- - [ Open an existing branch or worktree] ( #open-an-existing-branch-or-worktree )
22+ - [ Open an existing branch, tag or worktree] ( #open-an-existing-branch-tag -or-worktree )
2323 - [ Comparison with vanilla ` git-worktree ` ] ( #comparison-with-vanilla-git-worktree )
2424 - [ Create a new branch or worktree] ( #create-a-new-branch-or-worktree )
2525 - [ Comparison with vanilla ` git-worktree ` ] ( #comparison-with-vanilla-git-worktree-1 )
@@ -116,21 +116,28 @@ git config --local remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
116116git fetch
117117```
118118
119- ## Open an existing branch or worktree
119+ ## Open an existing branch, tag or worktree
120120
121- Switch to branch ` master ` and * cd* into its worktree, ** even if you are * cd'd* into
122- another worktree/branch** :
121+ Switch to ** branch** ` master ` :
123122
124123``` sh
125124git checkout master
126125```
127126
127+ You can also switch to an existing ** tag** :
128+ ``` sh
129+ git checkout v1.0.0
130+ ```
131+
132+ The script will automatically create the worktree, if it does not exist, and * cd*
133+ into it, ** even if you are * cd'd* into another worktree/branch/tag** :
134+
128135### Comparison with vanilla ` git-worktree `
129136
130137Next commands should be issued to achieve the same functionality described above when
131138` git-worktree-wrapper ` is not installed:
132139
133- If the branch exists but the worktree doesn't.
140+ If the branch/tag exists but the worktree doesn't.
134141``` language
135142cd /path/to/the/root/of/the/bare/repository
136143git worktree add master
@@ -145,14 +152,16 @@ cd master
145152
146153## Create a new branch or worktree
147154
148- Create a branch ` new_branch ` and * cd* into its new worktree, ** even if you are * cd'd* into
149- another worktree/branch** :
155+ To create a new branch, just issue the command you already know:
150156
151157``` sh
152158git checkout -b new_branch < from_branch (optional)>
153159# or use -B to force reset
154160```
155161
162+ The script will automatically create a new worktree and * cd* into it,
163+ ** even if you are * cd'd* into another worktree/branch/tag** :
164+
156165### Comparison with vanilla ` git-worktree `
157166
158167Next commands should be issued to achieve the same functionality described above when
@@ -176,11 +185,18 @@ git checkout -B new_branch <from_branch (optional)>
176185
177186## Delete a branch and its worktree
178187
179- Delete a branch and its worktree, ** even if you are * cd'd* into the worktree/branch you want to delete** :
188+ To delete a branch, just issue the command you already use for
189+ "normal" repositories:
190+
180191``` sh
181192git branch -d new_branch # or -D to force removal
182193```
183194
195+ The script will ** delete both** the branch and its worktree.
196+
197+ If you are * cd'd* into the worktree/branch you are deleting, the script will
198+ * cd* you into the root directory of the bare repository.
199+
184200### Comparison with vanilla ` git-worktree `
185201
186202Next commands should be issued to achieve the same functionality described above when
0 commit comments