git 1.6.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of git might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87d2d900d69f6d803a09dab4f7668b550bc21cecbf51194b494f8b9366dce3d7
4
- data.tar.gz: f8c1dc4b41a65b7c562f496f78a7d0f9f8ad98f26b70588186b5a890f058873b
3
+ metadata.gz: 1c98b8817ceb2d65efcf09cd2461023a5fb514fb738524332dbd98daae2b8cf0
4
+ data.tar.gz: 7fa575c50ed9f3c85bbd9aadd6e1d0a74d4421f9b3d612d43f761a1d77f7b1e2
5
5
  SHA512:
6
- metadata.gz: 9c4364cfc57fd1eb54be4c5229ca0b14b4d83227d08fabb57e0c326dee91be43bb1560376f013965f2377f651ad64900b5bd90ff96737855d8acdcb87cef7ac2
7
- data.tar.gz: 1d1114b7f1a2af9964e57e5cac34c8c88ffddebb39f79cdad89023827a3863697db435055c08961653a7a82c6cdf9f983e6c3b4119002c75b5f263acf2830e3e
6
+ metadata.gz: ecec9d8d598576983f48b9193ebadb4dc0a53745df0b0c27466ee075947945ea793dbb112107d4e5eaf70cca2cb93c3b0f83489af12d4b42d6336051261124ee
7
+ data.tar.gz: c164e57a0f9006672826c993719c85a8997e08b2272da7e48e17e945bffb9917d74cb3957ce09c9cb3b8cb4cec03f236b88f0334c5322a948e1f12021ffad5b7
data/.github/stale.yml ADDED
@@ -0,0 +1,25 @@
1
+ # Probot: Stale
2
+ # https://github.com/probot/stale
3
+
4
+ # Number of days of inactivity before an issue becomes stale
5
+ daysUntilStale: 60
6
+
7
+ # Number of days of inactivity before a stale issue is closed
8
+ # Set to false to disable. If disabled, issues still need to be closed
9
+ # manually, but will remain marked as stale.
10
+ daysUntilClose: false
11
+
12
+ # Issues with these labels will never be considered stale
13
+ exemptLabels:
14
+ - pinned
15
+ - security
16
+
17
+ # Label to use when marking an issue as stale
18
+ staleLabel: stale
19
+
20
+ # Comment to post when marking an issue as stale. Set to `false` to disable
21
+ markComment: >
22
+ A friendly reminder that this issue had no activity for 60 days.
23
+
24
+ # Comment to post when closing a stale issue. Set to `false` to disable
25
+ closeComment: false
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ continuous_integration_build:
11
+ continue-on-error: true
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [2.3, 2.7]
16
+ operating-system: [ubuntu-latest]
17
+ include:
18
+ - ruby: head
19
+ operating-system: ubuntu-latest
20
+ - ruby: truffleruby-head
21
+ operating-system: ubuntu-latest
22
+ - ruby: 2.7
23
+ operating-system: windows-latest
24
+ - ruby: jruby-head
25
+ operating-system: windows-latest
26
+
27
+ name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
28
+
29
+ runs-on: ${{ matrix.operating-system }}
30
+
31
+ steps:
32
+ - name: Checkout Code
33
+ uses: actions/checkout@v2
34
+
35
+ - name: Setup Ruby
36
+ uses: ruby/setup-ruby@v1
37
+ with:
38
+ ruby-version: ${{ matrix.ruby }}
39
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
40
+
41
+ - name: Run Build
42
+ run: bundle exec rake default
43
+
44
+ - name: Test Gem
45
+ run: bundle exec rake test:gem
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ *.kpf
3
+ *.sw?
4
+ .DS_Store
5
+ coverage
6
+ doc
7
+ .yardoc
8
+ pkg
9
+ rdoc
10
+ Gemfile.lock
data/.yardopts ADDED
@@ -0,0 +1,11 @@
1
+ --default-return=''
2
+ --hide-void-return
3
+ --markup-provider=redcarpet
4
+ --markup=markdown
5
+ --fail-on-warning
6
+ -
7
+ README.md
8
+ CHANGELOG.md
9
+ CONTRIBUTING.md
10
+ RELEASING.md
11
+ MAINTAINERS.md
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title Change Log
4
+ -->
5
+
1
6
  # Change Log
2
7
 
8
+ ## 1.9.1
9
+
10
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.1
11
+
12
+ ## 1.9.0
13
+
14
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.9.0
15
+
16
+ ## 1.8.1
17
+
18
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.1
19
+
20
+ ## 1.8.0
21
+
22
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.8.0
23
+
24
+ ## 1.7.0
25
+
26
+ See https://github.com/ruby-git/ruby-git/releases/tag/v1.7.0
27
+
3
28
  ## 1.6.0
4
29
 
5
30
  See https://github.com/ruby-git/ruby-git/releases/tag/v1.6.0
data/CONTRIBUTING.md CHANGED
@@ -1,3 +1,8 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title How To Contribute
4
+ -->
5
+
1
6
  # Contributing to ruby-git
2
7
 
3
8
  Thank you for your interest in contributing to the ruby-git project.
@@ -8,7 +13,7 @@ judgement.
8
13
 
9
14
  Propose changes to these guidelines with a pull request.
10
15
 
11
- ## How to contribute to ruby-git
16
+ ## How to contribute
12
17
 
13
18
  You can contribute in two ways:
14
19
 
@@ -73,12 +78,14 @@ In order to ensure high quality, all pull requests must meet these requirements:
73
78
 
74
79
  ### Unit tests
75
80
  * All changes must be accompanied by new or modified unit tests
76
- * The entire test suite must pass when `bundle exec rake test` is run from the
77
- project's local working copy
78
-
79
- ### Continuous Integration
80
- * All tests must pass in the project's [Travis CI](https://travis-ci.org/ruby-git/ruby-git)
81
- build before the pull request will be merged
81
+ * The entire test suite must pass when `bundle exec rake default` is run from the
82
+ project's local working copy.
83
+
84
+ ### Continuous integration
85
+ * All tests must pass in the project's [GitHub Continuous Integration build](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
86
+ before the pull request will be merged.
87
+ * The [Continuous Integration workflow](https://github.com/ruby-git/ruby-git/blob/master/.github/workflows/continuous_integration.yml)
88
+ runs both `bundle exec rake default` and `bundle exec rake test:gem` from the project's [Rakefile](https://github.com/ruby-git/ruby-git/blob/master/Rakefile).
82
89
 
83
90
  ### Documentation
84
91
  * New and updated public methods must have [YARD](https://yardoc.org/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'git'
4
+
data/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,15 @@
1
+ ### Subject of the issue
2
+ Describe your issue here.
3
+
4
+ ### Your environment
5
+ * version of git and ruby-git
6
+ * version of ruby
7
+
8
+ ### Steps to reproduce
9
+ Tell us how to reproduce this issue.
10
+
11
+ ### Expected behaviour
12
+ What did you expect to happen?
13
+
14
+ ### Actual behaviour
15
+ What actually happened?
data/MAINTAINERS.md CHANGED
@@ -1,3 +1,8 @@
1
+ <!--
2
+ # @markup markdown
3
+ # @title Maintainers
4
+ -->
5
+
1
6
  # Maintainers
2
7
 
3
8
  When making changes in this repository, one of the maintainers below must review and approve your pull request.
@@ -0,0 +1,9 @@
1
+ ### Your checklist for this pull request
2
+ 🚨Please review the [guidelines for contributing](https://github.com/ruby-git/ruby-git/blob/master/CONTRIBUTING.md) to this repository.
3
+
4
+ - [ ] Ensure all commits include DCO sign-off.
5
+ - [ ] Ensure that your contributions pass unit testing.
6
+ - [ ] Ensure that your contributions contain documentation if applicable.
7
+
8
+ ### Description
9
+ Please describe your pull request.
data/README.md CHANGED
@@ -1,24 +1,49 @@
1
- # Git Library for Ruby
1
+ <!--
2
+ # @markup markdown
3
+ # @title README
4
+ -->
2
5
 
3
- Library for using Git in Ruby.
6
+ # The Git Gem
7
+
8
+ The Git Gem provides an API that can be used to create, read, and manipulate
9
+ Git repositories by wrapping system calls to the `git` binary. The API can be
10
+ used for working with Git in complex interactions including branching and
11
+ merging, object inspection and manipulation, history, patch generation and
12
+ more.
4
13
 
5
14
  ## Homepage
6
15
 
7
- Git public hosting of the project source code is at:
16
+ The project source code is at:
8
17
 
9
18
  http://github.com/ruby-git/ruby-git
10
19
 
20
+ ## Documentation
21
+
22
+ Detailed documentation can be found at:
23
+
24
+ https://rubydoc.info/gems/git/Git.html
25
+
26
+ Get started by obtaining a repository object by:
27
+
28
+ * opening an existing working copy with [Git.open](https://rubydoc.info/gems/git/Git#open-class_method)
29
+ * initializing a new repository with [Git.init](https://rubydoc.info/gems/git/Git#init-class_method)
30
+ * cloning a repository with [Git.clone](https://rubydoc.info/gems/git/Git#clone-class_method)
31
+
32
+ Methods that can be called on a repository object are documented in [Git::Base](https://rubydoc.info/gems/git/Git/Base)
33
+
11
34
  ## Install
12
35
 
13
36
  You can install Ruby/Git like this:
14
37
 
15
- $ sudo gem install git
38
+ ```
39
+ sudo gem install git
40
+ ```
16
41
 
17
42
  ## Code Status
18
43
 
19
- * [![Build Status](https://travis-ci.org/ruby-git/ruby-git.svg?branch=master)](https://travis-ci.org/ruby-git/ruby-git)
44
+ * [![Build Status](https://github.com/ruby-git/ruby-git/workflows/CI/badge.svg?branch=master)](https://github.com/ruby-git/ruby-git/actions?query=workflow%3ACI)
20
45
  * [![Code Climate](https://codeclimate.com/github/ruby-git/ruby-git.png)](https://codeclimate.com/github/ruby-git/ruby-git)
21
- * [![Gem Version](https://badge.fury.io/rb/git.png)](http://badge.fury.io/rb/git)
46
+ * [![Gem Version](https://badge.fury.io/rb/git.svg)](https://badge.fury.io/rb/git)
22
47
 
23
48
  ## Major Objects
24
49
 
@@ -41,6 +66,8 @@ like:
41
66
 
42
67
  `@git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] }`
43
68
 
69
+ **Git::Worktrees** - Enumerable object that holds `Git::Worktree objects`.
70
+
44
71
  ## Examples
45
72
 
46
73
  Here are a bunch of examples of how to use the Ruby/Git package.
@@ -48,24 +75,24 @@ Here are a bunch of examples of how to use the Ruby/Git package.
48
75
  Ruby < 1.9 will require rubygems to be loaded.
49
76
 
50
77
  ```ruby
51
- require 'rubygems'
78
+ require 'rubygems'
52
79
  ```
53
80
 
54
81
  Require the 'git' gem.
55
82
  ```ruby
56
- require 'git'
83
+ require 'git'
57
84
  ```
58
85
 
59
86
  Git env config
60
87
 
61
88
  ```ruby
62
- Git.configure do |config|
63
- # If you want to use a custom git binary
64
- config.binary_path = '/git/bin/path'
89
+ Git.configure do |config|
90
+ # If you want to use a custom git binary
91
+ config.binary_path = '/git/bin/path'
65
92
 
66
- # If you need to use a custom SSH script
67
- config.git_ssh = '/path/to/ssh/script'
68
- end
93
+ # If you need to use a custom SSH script
94
+ config.git_ssh = '/path/to/ssh/script'
95
+ end
69
96
  ```
70
97
 
71
98
  _NOTE: Another way to specify where is the `git` binary is through the environment variable `GIT_PATH`_
@@ -73,226 +100,252 @@ _NOTE: Another way to specify where is the `git` binary is through the environme
73
100
  Here are the operations that need read permission only.
74
101
 
75
102
  ```ruby
76
- g = Git.open(working_dir, :log => Logger.new(STDOUT))
77
-
78
- g.index
79
- g.index.readable?
80
- g.index.writable?
81
- g.repo
82
- g.dir
83
-
84
- g.log # returns array of Git::Commit objects
85
- g.log.since('2 weeks ago')
86
- g.log.between('v2.5', 'v2.6')
87
- g.log.each {|l| puts l.sha }
88
- g.gblob('v2.5:Makefile').log.since('2 weeks ago')
89
-
90
- g.object('HEAD^').to_s # git show / git rev-parse
91
- g.object('HEAD^').contents
92
- g.object('v2.5:Makefile').size
93
- g.object('v2.5:Makefile').sha
94
-
95
- g.gtree(treeish)
96
- g.gblob(treeish)
97
- g.gcommit(treeish)
98
-
99
-
100
- commit = g.gcommit('1cc8667014381')
101
-
102
- commit.gtree
103
- commit.parent.sha
104
- commit.parents.size
105
- commit.author.name
106
- commit.author.email
107
- commit.author.date.strftime("%m-%d-%y")
108
- commit.committer.name
109
- commit.date.strftime("%m-%d-%y")
110
- commit.message
111
-
112
- tree = g.gtree("HEAD^{tree}")
113
-
114
- tree.blobs
115
- tree.subtrees
116
- tree.children # blobs and subtrees
117
-
118
- g.revparse('v2.5:Makefile')
119
-
120
- g.branches # returns Git::Branch objects
121
- g.branches.local
122
- g.branches.remote
123
- g.branches[:master].gcommit
124
- g.branches['origin/master'].gcommit
125
-
126
- g.grep('hello') # implies HEAD
127
- g.blob('v2.5:Makefile').grep('hello')
128
- g.tag('v2.5').grep('hello', 'docs/')
129
- g.describe()
130
- g.describe('0djf2aa')
131
- g.describe('HEAD', {:all => true, :tags => true})
132
-
133
- g.diff(commit1, commit2).size
134
- g.diff(commit1, commit2).stats
135
- g.diff(commit1, commit2).name_status
136
- g.gtree('v2.5').diff('v2.6').insertions
137
- g.diff('gitsearch1', 'v2.5').path('lib/')
138
- g.diff('gitsearch1', @git.gtree('v2.5'))
139
- g.diff('gitsearch1', 'v2.5').path('docs/').patch
140
- g.gtree('v2.5').diff('v2.6').patch
141
-
142
- g.gtree('v2.5').diff('v2.6').each do |file_diff|
143
- puts file_diff.path
144
- puts file_diff.patch
145
- puts file_diff.blob(:src).contents
146
- end
147
-
148
- g.config('user.name') # returns 'Scott Chacon'
149
- g.config # returns whole config hash
150
-
151
- g.tags # returns array of Git::Tag objects
152
-
153
- g.show()
154
- g.show('HEAD')
155
- g.show('v2.8', 'README.md')
156
-
157
- Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
158
- Git.ls_remote('/path/to/local/repo')
159
- Git.ls_remote() # same as Git.ls_remote('.')
160
-
103
+ g = Git.open(working_dir, :log => Logger.new(STDOUT))
104
+
105
+ g.index
106
+ g.index.readable?
107
+ g.index.writable?
108
+ g.repo
109
+ g.dir
110
+
111
+ g.log # returns array of Git::Commit objects
112
+ g.log.since('2 weeks ago')
113
+ g.log.between('v2.5', 'v2.6')
114
+ g.log.each {|l| puts l.sha }
115
+ g.gblob('v2.5:Makefile').log.since('2 weeks ago')
116
+
117
+ g.object('HEAD^').to_s # git show / git rev-parse
118
+ g.object('HEAD^').contents
119
+ g.object('v2.5:Makefile').size
120
+ g.object('v2.5:Makefile').sha
121
+
122
+ g.gtree(treeish)
123
+ g.gblob(treeish)
124
+ g.gcommit(treeish)
125
+
126
+
127
+ commit = g.gcommit('1cc8667014381')
128
+
129
+ commit.gtree
130
+ commit.parent.sha
131
+ commit.parents.size
132
+ commit.author.name
133
+ commit.author.email
134
+ commit.author.date.strftime("%m-%d-%y")
135
+ commit.committer.name
136
+ commit.date.strftime("%m-%d-%y")
137
+ commit.message
138
+
139
+ tree = g.gtree("HEAD^{tree}")
140
+
141
+ tree.blobs
142
+ tree.subtrees
143
+ tree.children # blobs and subtrees
144
+
145
+ g.revparse('v2.5:Makefile')
146
+
147
+ g.branches # returns Git::Branch objects
148
+ g.branches.local
149
+ g.current_branch
150
+ g.branches.remote
151
+ g.branches[:master].gcommit
152
+ g.branches['origin/master'].gcommit
153
+
154
+ g.grep('hello') # implies HEAD
155
+ g.blob('v2.5:Makefile').grep('hello')
156
+ g.tag('v2.5').grep('hello', 'docs/')
157
+ g.describe()
158
+ g.describe('0djf2aa')
159
+ g.describe('HEAD', {:all => true, :tags => true})
160
+
161
+ g.diff(commit1, commit2).size
162
+ g.diff(commit1, commit2).stats
163
+ g.diff(commit1, commit2).name_status
164
+ g.gtree('v2.5').diff('v2.6').insertions
165
+ g.diff('gitsearch1', 'v2.5').path('lib/')
166
+ g.diff('gitsearch1', @git.gtree('v2.5'))
167
+ g.diff('gitsearch1', 'v2.5').path('docs/').patch
168
+ g.gtree('v2.5').diff('v2.6').patch
169
+
170
+ g.gtree('v2.5').diff('v2.6').each do |file_diff|
171
+ puts file_diff.path
172
+ puts file_diff.patch
173
+ puts file_diff.blob(:src).contents
174
+ end
175
+
176
+ g.worktrees # returns Git::Worktree objects
177
+ g.worktrees.count
178
+ g.worktrees.each do |worktree|
179
+ worktree.dir
180
+ worktree.gcommit
181
+ worktree.to_s
182
+ end
183
+
184
+ g.config('user.name') # returns 'Scott Chacon'
185
+ g.config # returns whole config hash
186
+
187
+ g.tags # returns array of Git::Tag objects
188
+
189
+ g.show()
190
+ g.show('HEAD')
191
+ g.show('v2.8', 'README.md')
192
+
193
+ Git.ls_remote('https://github.com/ruby-git/ruby-git.git') # returns a hash containing the available references of the repo.
194
+ Git.ls_remote('/path/to/local/repo')
195
+ Git.ls_remote() # same as Git.ls_remote('.')
161
196
  ```
162
197
 
163
198
  And here are the operations that will need to write to your git repository.
164
199
 
165
200
  ```ruby
166
- g = Git.init
167
- Git.init('project')
168
- Git.init('/home/schacon/proj',
169
- { :repository => '/opt/git/proj.git',
170
- :index => '/tmp/index'} )
171
-
172
- g = Git.clone(URI, NAME, :path => '/tmp/checkout')
173
- g.config('user.name', 'Scott Chacon')
174
- g.config('user.email', 'email@email.com')
175
-
176
- g.add # git add -- "."
177
- g.add(:all=>true) # git add --all -- "."
178
- g.add('file_path') # git add -- "file_path"
179
- g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
180
-
181
- g.remove() # git rm -f -- "."
182
- g.remove('file.txt') # git rm -f -- "file.txt"
183
- g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
184
- g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
185
- g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
186
-
187
- g.commit('message')
188
- g.commit_all('message')
189
-
190
- g = Git.clone(repo, 'myrepo')
191
- g.chdir do
192
- new_file('test-file', 'blahblahblah')
193
- g.status.changed.each do |file|
194
- puts file.blob(:index).contents
195
- end
196
- end
197
-
198
- g.reset # defaults to HEAD
199
- g.reset_hard(Git::Commit)
200
-
201
- g.branch('new_branch') # creates new or fetches existing
202
- g.branch('new_branch').checkout
203
- g.branch('new_branch').delete
204
- g.branch('existing_branch').checkout
205
- g.branch('master').contains?('existing_branch')
206
-
207
- g.checkout('new_branch')
208
- g.checkout(g.branch('new_branch'))
209
-
210
- g.branch(name).merge(branch2)
211
- g.branch(branch2).merge # merges HEAD with branch2
212
-
213
- g.branch(name).in_branch(message) { # add files } # auto-commits
214
- g.merge('new_branch')
215
- g.merge('origin/remote_branch')
216
- g.merge(g.branch('master'))
217
- g.merge([branch1, branch2])
218
-
219
- g.merge_base('branch1', 'branch2')
220
-
221
- r = g.add_remote(name, uri) # Git::Remote
222
- r = g.add_remote(name, Git::Base) # Git::Remote
223
-
224
- g.remotes # array of Git::Remotes
225
- g.remote(name).fetch
226
- g.remote(name).remove
227
- g.remote(name).merge
228
- g.remote(name).merge(branch)
229
-
230
- g.fetch
231
- g.fetch(g.remotes.first)
232
- g.fetch('origin', {:ref => 'some/ref/head'} )
233
-
234
- g.pull
235
- g.pull(Git::Repo, Git::Branch) # fetch and a merge
236
-
237
- g.add_tag('tag_name') # returns Git::Tag
238
- g.add_tag('tag_name', 'object_reference')
239
- g.add_tag('tag_name', 'object_reference', {:options => 'here'})
240
- g.add_tag('tag_name', {:options => 'here'})
241
-
242
- Options:
243
- :a | :annotate
244
- :d
245
- :f
246
- :m | :message
247
- :s
248
-
249
- g.delete_tag('tag_name')
250
-
251
- g.repack
252
-
253
- g.push
254
- g.push(g.remote('name'))
201
+ g = Git.init
202
+ Git.init('project')
203
+ Git.init('/home/schacon/proj',
204
+ { :repository => '/opt/git/proj.git',
205
+ :index => '/tmp/index'} )
206
+
207
+ g = Git.clone(URI, NAME, :path => '/tmp/checkout')
208
+ g.config('user.name', 'Scott Chacon')
209
+ g.config('user.email', 'email@email.com')
210
+
211
+ # Clone can take an optional logger
212
+ logger = Logger.new
213
+ g = Git.clone(URI, NAME, :log => logger)
214
+
215
+ g.add # git add -- "."
216
+ g.add(:all=>true) # git add --all -- "."
217
+ g.add('file_path') # git add -- "file_path"
218
+ g.add(['file_path_1', 'file_path_2']) # git add -- "file_path_1" "file_path_2"
219
+
220
+ g.remove() # git rm -f -- "."
221
+ g.remove('file.txt') # git rm -f -- "file.txt"
222
+ g.remove(['file.txt', 'file2.txt']) # git rm -f -- "file.txt" "file2.txt"
223
+ g.remove('file.txt', :recursive => true) # git rm -f -r -- "file.txt"
224
+ g.remove('file.txt', :cached => true) # git rm -f --cached -- "file.txt"
225
+
226
+ g.commit('message')
227
+ g.commit_all('message')
228
+
229
+ # Sign a commit using the gpg key configured in the user.signingkey config setting
230
+ g.config('user.signingkey', '0A46826A')
231
+ g.commit('message', gpg_sign: true)
232
+
233
+ # Sign a commit using a specified gpg key
234
+ key_id = '0A46826A'
235
+ g.commit('message', gpg_sign: key_id)
236
+
237
+ g = Git.clone(repo, 'myrepo')
238
+ g.chdir do
239
+ new_file('test-file', 'blahblahblah')
240
+ g.status.changed.each do |file|
241
+ puts file.blob(:index).contents
242
+ end
243
+ end
244
+
245
+ g.reset # defaults to HEAD
246
+ g.reset_hard(Git::Commit)
247
+
248
+ g.branch('new_branch') # creates new or fetches existing
249
+ g.branch('new_branch').checkout
250
+ g.branch('new_branch').delete
251
+ g.branch('existing_branch').checkout
252
+ g.branch('master').contains?('existing_branch')
253
+
254
+ g.checkout('new_branch')
255
+ g.checkout(g.branch('new_branch'))
256
+
257
+ g.branch(name).merge(branch2)
258
+ g.branch(branch2).merge # merges HEAD with branch2
259
+
260
+ g.branch(name).in_branch(message) { # add files } # auto-commits
261
+ g.merge('new_branch')
262
+ g.merge('new_branch', 'merge commit message', no_ff: true)
263
+ g.merge('origin/remote_branch')
264
+ g.merge(g.branch('master'))
265
+ g.merge([branch1, branch2])
266
+
267
+ g.merge_base('branch1', 'branch2')
268
+
269
+ r = g.add_remote(name, uri) # Git::Remote
270
+ r = g.add_remote(name, Git::Base) # Git::Remote
271
+
272
+ g.remotes # array of Git::Remotes
273
+ g.remote(name).fetch
274
+ g.remote(name).remove
275
+ g.remote(name).merge
276
+ g.remote(name).merge(branch)
277
+
278
+ g.fetch
279
+ g.fetch(g.remotes.first)
280
+ g.fetch('origin', {:ref => 'some/ref/head'} )
281
+
282
+ g.pull
283
+ g.pull(Git::Repo, Git::Branch) # fetch and a merge
284
+
285
+ g.add_tag('tag_name') # returns Git::Tag
286
+ g.add_tag('tag_name', 'object_reference')
287
+ g.add_tag('tag_name', 'object_reference', {:options => 'here'})
288
+ g.add_tag('tag_name', {:options => 'here'})
289
+
290
+ Options:
291
+ :a | :annotate
292
+ :d
293
+ :f
294
+ :m | :message
295
+ :s
296
+
297
+ g.delete_tag('tag_name')
298
+
299
+ g.repack
300
+
301
+ g.push
302
+ g.push(g.remote('name'))
303
+
304
+ g.worktree('/tmp/new_worktree').add
305
+ g.worktree('/tmp/new_worktree', 'branch1').add
306
+ g.worktree('/tmp/new_worktree').remove
307
+ g.worktrees.prune
255
308
  ```
256
309
 
257
310
  Some examples of more low-level index and tree operations
258
311
 
259
312
  ```ruby
260
- g.with_temp_index do
313
+ g.with_temp_index do
261
314
 
262
- g.read_tree(tree3) # calls self.index.read_tree
263
- g.read_tree(tree1, :prefix => 'hi/')
315
+ g.read_tree(tree3) # calls self.index.read_tree
316
+ g.read_tree(tree1, :prefix => 'hi/')
264
317
 
265
- c = g.commit_tree('message')
266
- # or #
267
- t = g.write_tree
268
- c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
318
+ c = g.commit_tree('message')
319
+ # or #
320
+ t = g.write_tree
321
+ c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2])
269
322
 
270
- g.branch('branch_name').update_ref(c)
271
- g.update_ref(branch, c)
323
+ g.branch('branch_name').update_ref(c)
324
+ g.update_ref(branch, c)
272
325
 
273
- g.with_temp_working do # new blank working directory
274
- g.checkout
275
- g.checkout(another_index)
276
- g.commit # commits to temp_index
277
- end
278
- end
326
+ g.with_temp_working do # new blank working directory
327
+ g.checkout
328
+ g.checkout(another_index)
329
+ g.commit # commits to temp_index
330
+ end
331
+ end
279
332
 
280
- g.set_index('/path/to/index')
333
+ g.set_index('/path/to/index')
281
334
 
282
335
 
283
- g.with_index(path) do
284
- # calls set_index, then switches back after
285
- end
336
+ g.with_index(path) do
337
+ # calls set_index, then switches back after
338
+ end
286
339
 
287
- g.with_working(dir) do
288
- # calls set_working, then switches back after
289
- end
340
+ g.with_working(dir) do
341
+ # calls set_working, then switches back after
342
+ end
290
343
 
291
- g.with_temp_working(dir) do
292
- g.checkout_index(:prefix => dir, :path_limiter => path)
293
- # do file work
294
- g.commit # commits to index
295
- end
344
+ g.with_temp_working(dir) do
345
+ g.checkout_index(:prefix => dir, :path_limiter => path)
346
+ # do file work
347
+ g.commit # commits to index
348
+ end
296
349
  ```
297
350
 
298
351
  ## License