User Tools

Site Tools


git_worktree

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:29]
rpjday [Creating the linked working tree]
git_worktree [2019/03/06 08:24] (current)
rpjday [Additional issues to cover]
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 147: Line 146:
 <​code>​ <​code>​
 $ git worktree add -b emergency ../temp 2.1.100 $ git worktree add -b emergency ../temp 2.1.100
-Preparing ​../​temp ​(identifier temp+Preparing ​worktree ​(new branch '​emergency'​
-HEAD is now at 90bdf0a Stahp updating bundler+HEAD is now at f2d0827 Merge pull request #1145 from rpjday/​topic/​rpjday/​maintaining
 $ $
 </​code>​ </​code>​
Line 185: Line 184:
 <​code>​ <​code>​
 $ pushd ../temp $ pushd ../temp
 +</​code>​
 +
 +Check the status:
 +
 +<​code>​
 +$ git status
 +On branch emergency
 +nothing to commit, working tree clean
 +$
 </​code>​ </​code>​
  
Line 197: Line 205:
  
 Verify current branch, and current position in history: Verify current branch, and current position in history:
- 
-<​code>​ 
-$ git status 
-On branch emergency 
-nothing to commit, working tree clean 
-$ 
-</​code>​ 
  
 <​code>​ <​code>​
 $ git show $ git show
-commit ​90bdf0a2cb410463a949ae9279ac7e065f7b023b ​(HEAD -> emergency, tag: 2.1.30)+commit ​f2d082747b0a9474f9d2d08c6945482b55691e4a ​(HEAD -> emergency, tag: 2.1.100) 
 +Merge: 7a13f5a 5c0663e
 Author: Ben Straub <​ben@straub.cc>​ Author: Ben Straub <​ben@straub.cc>​
-Date:   Tue Jan 16 10:31:13 2018 -0800+Date:   Mon Dec 10 10:06:11 2018 -0800
  
-    ​Stahp updating bundler+    ​Merge pull request #1145 from rpjday/​topic/​rpjday/​maintaining 
 +     
 +    maintaining:​ explain how "git describe"​ works with lightweight tags
  
-diff --git a/​.travis.yml b/​.travis.yml 
-index 9d0bcb2..cffacfd 100644 
---- a/​.travis.yml 
-+++ b/​.travis.yml 
-@@ -1,7 +1,6 @@ 
- ​language:​ ruby 
- ​cache:​ bundler 
- ​before_install:​ 
--- gem install bundler 
- - bundle install 
- ​after_success:​ 
- - script/​tag_on_master 
 $ $
 </​code>​ </​code>​
  
-Examine the ''​.git''​ //file// in the linked working tree:+Examine the ''​.git''​ //file// in this linked working tree -- this is what identifies a linked working tree:
  
 <​code>​ <​code>​
Line 235: 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 288: 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.1551014975.txt.gz · Last modified: 2019/02/24 13:29 by rpjday