moved the git objects into the object.rb file
[rubygit.git] / README
blobb47fac089823f2953733fb3ad25519896383127d
1 Git Library for Ruby
2 -----------------------------
4 Git
5 Git::Repository
6 Git::Index 
7 Git::WorkingDirectory << Dir
9 Git::Object 
11 Git::Commit << Git::Object
12 Git::Blob
13 Git::Tree
14 Git::Tag
16 Git::Author
17 Git::Ref 
18 Git::File (in working dir)
19 Git::Log
20 Git::Sha
21 Git::Diff
22 Git::Branch 
23 Git::Remote << Git::Repository
25 require 'git'
28 # needs read permission only
30 g = Git.open (working_dir = '.')
31         (git_dir, index_file)
33 g.index
34 g.index.readable?
35 g.index.writable?
36 g.repo
37 g.dir
39 g.log   # returns array of Git::Commit objects
40 g.log.since('2 weeks ago')
41 g.log.between('v2.5', 'v2.6')
42 g.log.since('v2.5').file('Makefile')
43 g.log.each {|l| puts l.sha }
45 **********
48 g.object('HEAD^').to_s  # git show / git rev-parse
50 g.rev_parse('HEAD^')
51 g.rev_parse('v2.5:Makefile')  # returns Git::Object
54 g.file('flim/ChangeLog').tags.each {|tag,rev| p [tag,rev.to_s]}
55 g.file('flim/ChangeLog').logs.each { |log| log.sha }
57 g.branches # returns Git::Branch objects
58 g.branches.local
59 g.branches.remote
61 g.status
63 g.tag # returns array of Git::Tag objects
66 g.grep('hello')
67 g.grep('hello', Git::Tag)
69 g.ls_files
70 g.ls_files(:stage => true)
72 g.diff
73 g.diff_cached
74 g.diff(commit1, commit2)
75 g.diff("commit1..commit2")
77 g.diff_tree(Git::Tree, Git::Tree)
80 c = Git::Commit.new("HEAD^^")
81 c = Git::Commit.new("394839")
84 # needs write permission
86 g = Git.clone(URI, 'name', working_dir = GIT_DIR, {options})
87         (username, password, ssl_key, git_dir, index_file)
89 g = Git.init
90   Git.init('project')
91   Git.init('/home/schacon/proj', 
92                 { :git_dir => '/opt/git/proj.git', 
93                   :index_file => '/tmp/index'} )
97 g.config('user.name', 'Scott Chacon')
98 g.config('user.email', 'email@email.com')
99 g.config('user.name')  # returns 'Scott Chacon'
100 g.config # returns whole config hash
102 g.add('.')
103 g.add([file1, file2])
105 g.remove('file.txt').and_file
107 g.commit('message')
108 g.commit_a('message')
110 g.reset # defaults to HEAD
111 g.reset_hard(Git::Commit)
113 g.branch('new_branch')
114 g.branch('new_branch').delete
116 g.checkout('new_branch')
117 g.checkout('new_branch', :create_branch => true)
118 g.checkout_b('new_branch')
120 g.merge('new_branch')
121 g.merge(Git::Branch)
122 g.merge(Git::Branch, Git::Branch)
124 g.fetch
125 g.fetch(Git::Repo)
127 g.pull
128 g.pull(Git::Repo, Git::Branch) # fetch and a merge
130 g.tag('tag_name') # returns Git::Tag
132 g.pack
136 Git::Object
137   - sha
138   - type
139   - cat_file
140   - raw
142 Git::Commit
143   - tree
144   - parent 
145   - author      # git author
146   - author_date
147   - committer   # git author
148   - committer_date / date
149   - message
151 Git::Tree
152   - children
153   - blobs/files
154   - subtrees/subdirs
156 Git::Blob << File
157   - size
158   - permissions
160 Git::Tag
162 Git::Hash
163   - abbrev/short
165 Git::Repository
166   - heads
167   - refs
168   - branches
170 Git::WorkingDirectory 
171   - foreach
172   - glob # returns Git::Files
174 Git::File << File
175   - log
176   - tags