1 <?xml version=
"1.0" encoding=
"iso-8859-1"?>
3 PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
8 <title>File: EXAMPLES
</title>
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1" />
10 <meta http-equiv=
"Content-Script-Type" content=
"text/javascript" />
11 <link rel=
"stylesheet" href=
".././rdoc-style.css" type=
"text/css" media=
"screen" />
12 <script type=
"text/javascript">
15 function popupCode( url ) {
16 window.open(url,
"Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
19 function toggleCode( id ) {
20 if ( document.getElementById )
21 elem = document.getElementById( id );
22 else if ( document.all )
23 elem = eval(
"document.all." + id );
27 elemStyle = elem.style;
29 if ( elemStyle.display !=
"block" ) {
30 elemStyle.display =
"block"
32 elemStyle.display =
"none"
38 // Make codeblocks hidden by default
39 document.writeln(
"<style type=\"text/css\
">div.method-source-code { display: none }</style>" )
51 <table class=
"header-table">
52 <tr class=
"top-aligned-row">
53 <td><strong>Path:
</strong></td>
57 <tr class=
"top-aligned-row">
58 <td><strong>Last Update:
</strong></td>
59 <td>Sun Nov
11 17:
51:
57 PST
2007</td>
63 <!-- banner header -->
65 <div id=
"bodyContent">
69 <div id=
"contextContent">
71 <div id=
"description">
73 require
‘git
’
76 # needs read permission only
79 g =
<a href=
"../classes/Git.html#M000002">Git.open
</a> (working_dir =
86 g.index g.index.readable? g.index.writable? g.repo g.dir
89 g.log # returns array of Git::Commit objects g.log.since(
‘2 weeks
90 ago
’) g.log.between(
‘v2.5
’,
‘v2.6
’)
91 g.log.each {|l| puts l.sha }
92 g.gblob(
‘v2.5:Makefile
’).log.since(
‘2 weeks ago
’)
95 g.object(
‘HEAD^
’).to_s # git show / git rev-parse
96 g.object(
‘HEAD^
’).contents
97 g.object(
‘v2.5:Makefile
’).size
98 g.object(
‘v2.5:Makefile
’).sha
101 g.gtree(treeish) g.gblob(treeish) g.gcommit(treeish)
104 g.revparse(
‘v2.5:Makefile
’)
107 g.branches # returns
<a href=
"../classes/Git/Branch.html">Git::Branch
</a>
108 objects g.branches.local g.branches.remote g.branches[:master].gcommit
109 g.branches[
‘origin/master
’].gcommit
112 g.grep(
‘hello
’) # implies HEAD
113 g.blob(
‘v2.5:Makefile
’).grep(
‘hello
’)
114 g.tag(
‘v2.5
’).grep(
‘hello
’,
‘docs/
’)
117 g.diff(commit1, commit2).size g.diff(commit1, commit2).stats
118 g.gtree(
‘v2.5
’).diff(
‘v2.6
’).insertions
119 g.diff(
‘gitsearch1
’,
120 ‘v2.5
’).path(
‘lib/
’)
121 g.diff(
‘gitsearch1
’, @git.gtree(
‘v2.5
’))
122 g.diff(
‘gitsearch1
’,
123 ‘v2.5
’).path(
‘docs/
’).patch
124 g.gtree(
‘v2.5
’).diff(
‘v2.6
’).patch
127 g.gtree(
‘v2.5
’).diff(
‘v2.6
’).each do |file_diff|
132 puts file_diff.blob(:src).contents
138 g.config(
‘user.name
’) # returns
‘Scott Chacon
’
139 g.config # returns whole config hash
142 g.tag # returns array of Git::Tag objects
145 # needs write permission
148 g =
<a href=
"../classes/Git.html#M000003">Git.init
</a>
152 Git.init('/home/schacon/proj',
153 { :git_dir =
> '/opt/git/proj.git',
154 :index_file =
> '/tmp/index'} )
157 g =
<a href=
"../classes/Git.html#M000004">Git.clone
</a>(URI, :name =
>
158 ‘name
’, :path =
> ’/tmp/checkout
‘
161 (git_dir, index_file)
164 g.config(
‘user.name
’,
‘Scott Chacon
’)
165 g.config(
‘user.email
’,
‘email@email.com
’)
168 g.add(
’.
’) g.add([file1, file2])
171 g.remove(
‘file.txt
’) g.remove([
‘file.txt
’,
172 ‘file2.txt
’])
175 g.commit(
‘message
’) g.commit_all(
‘message
’)
178 g =
<a href=
"../classes/Git.html#M000004">Git.clone
</a>(repo,
179 ‘myrepo
’) Dir.chdir(
‘myrepo
’) do
182 new_file('test-file', 'blahblahblah')
183 g.status.untracked.each do |file|
184 puts file.blob(:index).contents
191 g.reset # defaults to HEAD g.reset_hard(Git::Commit)
194 g.branch(
‘new_branch
’) # creates new or fetches existing
195 g.branch(
‘new_branch
’).checkout
196 g.branch(
‘new_branch
’).delete
197 g.branch(
‘existing_branch
’).checkout
200 g.checkout(
‘new_branch
’)
201 g.checkout(g.branch(
‘new_branch
’))
204 g.branch(name).merge(branch2) g.branch(branch2).merge # merges HEAD with
208 g.branch(name).in_branch(message) { # add files } # auto-commits
209 g.merge(
‘new_branch
’)
210 g.merge(
‘origin/remote_branch
’)
211 g.merge(b.branch(
‘master
’)) g.merge([branch1, branch2])
214 r = g.add_remote(name, uri) #
<a
215 href=
"../classes/Git/Remote.html">Git::Remote
</a> r = g.add_remote(name,
<a
216 href=
"../classes/Git/Base.html">Git::Base
</a>) #
<a
217 href=
"../classes/Git/Remote.html">Git::Remote
</a>
220 g.remotes # array of Git::Remotes g.remote(name).fetch
221 g.remote(name).remove g.remote(name).merge g.remote(name).merge(branch)
224 g.fetch g.fetch(g.remotes.first)
227 g.pull g.pull(Git::Repo,
<a
228 href=
"../classes/Git/Branch.html">Git::Branch
</a>) # fetch and a merge
231 g.add_tag(
‘tag_name
’) # returns Git::Tag
257 <!-- if method_list -->
263 <div id=
"validator-badges">
264 <p><small><a href=
"http://validator.w3.org/check/referer">[Validate]
</a></small></p>