Skip to content

Commit 757eb86

Browse files
Add worktree docs
1 parent 820c7b7 commit 757eb86

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ like:
4141

4242
`@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
4343

44+
**Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
45+
4446
## Examples
4547

4648
Here are a bunch of examples of how to use the Ruby/Git package.
@@ -145,6 +147,14 @@ Here are the operations that need read permission only.
145147
puts file_diff.blob(:src).contents
146148
end
147149

150+
g.worktrees # returns Git::Worktree objects
151+
g.worktrees.count
152+
g.worktrees.each do |worktree|
153+
worktree.dir
154+
worktree.gcommit
155+
worktree.to_s
156+
end
157+
148158
g.config('user.name') # returns 'Scott Chacon'
149159
g.config # returns whole config hash
150160

@@ -252,6 +262,11 @@ And here are the operations that will need to write to your git repository.
252262

253263
g.push
254264
g.push(g.remote('name'))
265+
266+
g.worktree('/tmp/new_worktree').add
267+
g.worktree('/tmp/new_worktree', 'branch1').add
268+
g.worktree('/tmp/new_worktree').remove
269+
g.worktrees.prune
255270
```
256271

257272
Some examples of more low-level index and tree operations

0 commit comments

Comments
 (0)