Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_worktree [2019/02/24 13:33] – [Move to new working tree] rpjdaygit_worktree [2019/03/06 08:24] (current) – [Additional issues to cover] rpjday
Line 97: Line 97:
 ==== Remove the worktree ==== ==== Remove the worktree ====
  
-If you have no further use for the worktree, remove and prune, which has no effect on the branch that was created:+If you have no further use for the worktree, remove it, which has no effect on the branch that was created:
  
 <code> <code>
 $ git worktree remove ../temp $ git worktree remove ../temp
-$ git worktree prune 
 $ git branch $ git branch
   emergency   emergency
Line 221: Line 220:
 </code> </code>
  
-Examine the ''.git'' //file// in this linked working tree:+Examine the ''.git'' //file// in this linked working tree -- this is what identifies a linked working tree:
  
 <code> <code>
Line 228: Line 227:
 $ $
 </code> </code>
-==== Commit some work in the new working tree ====+==== Make and commit a change in the worktree ==== 
 + 
 +Make a change, and stage it:
  
 <code> <code>
-$ git diff+$ git diff --cached
 diff --git a/README.asc b/README.asc diff --git a/README.asc b/README.asc
-index d7810fd..0576243 100644+index fa40bad..9d69d12 100644
 --- a/README.asc --- a/README.asc
 +++ b/README.asc +++ b/README.asc
-@@ -1,+1,@@ +@@ -1,+1,@@ 
--= Pro Git, Second Edition ++Change to README.asc on emergency branch in worktree 
-+= Pro Git, Second Edition (rday)++ 
 + = Pro Git, Second Edition
    
  Welcome to the second edition of the Pro Git book.  Welcome to the second edition of the Pro Git book.
-  
 $ $
 </code> </code>
 +
 +Commit:
  
 <code> <code>
-$ git commit -a -m "silly change+$ git commit -m "Change README.asc in worktree
-[emergency 6bf829dsilly change +[emergency 8b31c7bChange README.asc in worktree 
- 1 file changed, 1 insertion(+), 1 deletion(-)+ 1 file changed, 2 insertions(+)
 $ $
 </code> </code>
 +
 +Verify:
  
 <code> <code>
 $ git show $ git show
-commit 6bf829d7e63b1184c73546aa94625849054b1ebc (HEAD -> emergency)+commit 8b31c7b18e22fddca50eb9af706b6927f2c14ddc (HEAD -> emergency)
 Author: Robert P. J. Day <rpjday@crashcourse.ca> Author: Robert P. J. Day <rpjday@crashcourse.ca>
-Date:   Tue Feb 6 09:48:48 2018 -0500+Date:   Sun Feb 24 08:36:12 2019 -0500
  
-    silly change+    Change README.asc in worktree
  
 diff --git a/README.asc b/README.asc diff --git a/README.asc b/README.asc
-index d7810fd..0576243 100644+index fa40bad..9d69d12 100644
 --- a/README.asc --- a/README.asc
 +++ b/README.asc +++ b/README.asc
-@@ -1,+1,@@ +@@ -1,+1,@@ 
--= Pro Git, Second Edition ++Change to README.asc on emergency branch in worktree 
-+= Pro Git, Second Edition (rday)++ 
 + = Pro Git, Second Edition
    
  Welcome to the second edition of the Pro Git book.  Welcome to the second edition of the Pro Git book.
-  
 $ $
 </code> </code>
Line 281: Line 286:
 </code> </code>
  
-Still on ''master'' branch:+Everything here is just where we left it:
  
 <code> <code>
 $ git status $ git status
 On branch master On branch master
-Your branch is up-to-date with 'origin/master'.+Your branch is up to date with 'rpjday/master'.
  
-nothing to commit, working tree clean +Changes to be committed: 
-$ +  (use "git reset HEAD <file>..." to unstage)
-</code>+
  
-Linked working tree is still there and available:+ modified:   README.asc 
 + 
 +Changes not staged for commit: 
 +  (use "git add <file>..." to update what will be committed) 
 +  (use "git checkout -- <file>..." to discard changes in working directory) 
 + 
 + modified  LICENSE.asc
  
-<code> 
-$ git branch 
-  emergency 
-* master 
 $ $
 </code> </code>
 +
 +Linked working tree and ''emergency'' branch are still there:
  
 <code> <code>
 $ git worktree list $ git worktree list
-/home/rpjday/ebooks/progit/progit2  dd124f7 [master] +/home/rpjday/ebooks/progit/progit2  5df317d [master] 
-/home/rpjday/ebooks/progit/temp     6bf829d [emergency]+/home/rpjday/ebooks/progit/temp     8b31c7b [emergency]
 $ $
 </code> </code>
  
 <code> <code>
-$ git show emergency +$ git branch 
-commit 6bf829d7e63b1184c73546aa94625849054b1ebc (emergency+  emergency 
-Author: Robert P. J. Day <rpjday@crashcourse.ca> +* master
-Date:   Tue Feb 6 09:48:48 2018 -0500 +
- +
-    silly change +
- +
-diff --git a/README.asc b/README.asc +
-index d7810fd..0576243 100644 +
---- a/README.asc +
-+++ b/README.asc +
-@@ -1,4 +1,4 @@ +
--= Pro Git, Second Edition +
-+= Pro Git, Second Edition (rday) +
-  +
- Welcome to the second edition of the Pro Git book. +
- +
 $ $
 </code> </code>
 +
 +What you choose to do with the work committed to the ''emergency'' branch is up to you.
  
 ==== Remove working tree ==== ==== Remove working tree ====
  
-Remove the directory itself:+Once you're done with the worktree, remove it and "prune" it:
  
 <code> <code>
-rm -rf ../temp +git worktree remove ../temp 
-</code> +[rpjday@localhost progit2]$ git worktree list 
- +/home/rpjday/ebooks/progit/progit2  5df317d [master]
-Still seems to be there: +
- +
-<code> +
-$ git worktree list +
-/home/rpjday/ebooks/progit/progit2  dd124f7 [master+
-/home/rpjday/ebooks/progit/temp     6bf829d [emergency]+
 $ $
 </code> </code>
  
-We need to "prune" deleted working trees:+Note that the ''emergency'' branch still exists.
  
 <code> <code>
-$ git worktree prune +$ git branch 
-[rpjday@android-a172fe96dd584b41 progit2]$ git worktree list +  emergency 
-/home/rpjday/ebooks/progit/progit2  dd124f7 [master] +* master
-+
-</code> +
- +
-But our work that was committed from that working tree is still there in the object store: +
- +
-<code> +
-$ git show emergency +
-commit 6bf829d7e63b1184c73546aa94625849054b1ebc (emergency) +
-Author: Robert P. J. Day <rpjday@crashcourse.ca> +
-Date:   Tue Feb 6 09:48:48 2018 -0500 +
- +
-    silly change +
- +
-diff --git a/README.asc b/README.asc +
-index d7810fd..0576243 100644 +
---- a/README.asc +
-+++ b/README.asc +
-@@ -1,4 +1,4 @@ +
--= Pro Git, Second Edition +
-+= Pro Git, Second Edition (rday) +
-  +
- Welcome to the second edition of the Pro Git book. +
- +
 $ $
 </code> </code>
  
-===== Additional issues =====+===== Additional issues to cover =====
  
   * locking and unlocking working trees   * locking and unlocking working trees
   * moving working trees   * moving working trees
-  * gc.worktreePruneExpire +  * git config %%--%%worktree (man git-config)
-  * git config --worktree (man git-config)+
   * config var ''extensions.worktreeConfig''   * config var ''extensions.worktreeConfig''
   * config var ''gc.worktreePruneExpire''   * config var ''gc.worktreePruneExpire''
  • git_worktree.1551015221.txt.gz
  • Last modified: 2019/02/24 13:33
  • by rpjday