3 # needs read permission only
5 g = Git.open (working_dir = '.')
14 g.log # returns array of Git::Commit objects
15 g.log.since('2 weeks ago')
16 g.log.between('v2.5', 'v2.6')
17 g.log.each {|l| puts l.sha }
18 g.blob('v2.5:Makefile').log.since('2 weeks ago')
20 g.object('HEAD^').to_s # git show / git rev-parse
21 g.object('HEAD^').contents
22 g.object('v2.5:Makefile').size
23 g.object('v2.5:Makefile').sha
29 g.revparse('v2.5:Makefile')
31 g.branches # returns Git::Branch objects
34 g.branches[:master].commit
35 g.branches['origin/master'].commit
37 g.grep('hello') # implies HEAD
38 g.blob('v2.5:Makefile').grep('hello')
39 g.tag('v2.5').grep('hello', 'docs/')
41 g.diff(commit1, commit2).size
42 g.diff(commit1, commit2).stats
43 g.tree('v2.5').diff('v2.6').insertions
44 g.diff('gitsearch1', 'v2.5').path('lib/')
45 g.diff('gitsearch1', @git.tree('v2.5'))
46 g.diff('gitsearch1', 'v2.5').path('docs/').patch
47 g.tree('v2.5').diff('v2.6').patch
49 g.tree('v2.5').diff('v2.6').each do |file_diff|
52 puts file_diff.blob(:src).contents
55 g.config('user.name') # returns 'Scott Chacon'
56 g.config # returns whole config hash
58 ***** IMPLEMENTED *****
61 g.ls_files(:stage => true)
63 g.tag # returns array of Git::Tag objects
72 # needs write permission
77 Git.init('/home/schacon/proj',
78 { :git_dir => '/opt/git/proj.git',
79 :index_file => '/tmp/index'} )
82 ***** IMPLEMENTED *****
85 g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout'
86 (username, password, ssl_key, git_dir, index_file)
90 g.config('user.name', 'Scott Chacon')
91 g.config('user.email', 'email@email.com')
96 g.remove('file.txt').and_file
101 g.reset # defaults to HEAD
102 g.reset_hard(Git::Commit)
104 g.branch('new_branch')
105 g.branch('new_branch').delete
107 g.checkout('new_branch')
108 g.checkout('new_branch', :create_branch => true)
109 g.checkout_b('new_branch')
111 g.merge('new_branch')
113 g.merge(Git::Branch, Git::Branch)
119 g.pull(Git::Repo, Git::Branch) # fetch and a merge
121 g.tag('tag_name') # returns Git::Tag