@@ -20,7 +20,31 @@ is my working repository and contains the ``.git`` directory. You can also
2020initialize GitPython with a bare repository.
2121
2222 >>> repo = Repo.create(" /var/git/git-python.git" )
23+
24+ A repo object provides high-level access to your data, it allows you to create
25+ and delete heads, tags and remotes and access the configuration of the
26+ repository.
27+
28+ >>> repo.config_reader() # get a config reader for read-only access
29+ >>> repo.config_writer() # get a config writer to change configuration
30+
31+ Query the active branch, query untracked files or whether the repository data
32+ has been modified.
33+
34+ >>> repo.is_dirty()
35+ False
36+ >>> repo.untracked_files()
37+ ['my_untracked_file']
38+
39+ Clone from existing repositories or initialize new empty ones.
2340
41+ >>> cloned_repo = repo.clone(" to/this/path" )
42+ >>> new_repo = repo.init(" path/for/new/repo" )
43+
44+ Archive the repository contents to a tar file.
45+
46+ >>> repo.archive(open (" repo.tar" ,' w' ))
47+
2448Examining References
2549********************
2650
@@ -241,9 +265,55 @@ method to obtain an iterator to access entries recursively.
241265 >>> for entry in traverse(): do_something(entry)
242266
243267
268+ The Index Object
269+ ****************
270+ The git index is the stage containing changes to be written to the next commit
271+ or where merges finally have to take place. You may freely access and manipulate
272+ this information using the Index Object.
273+
274+ >>> index = repo.index
275+
276+ Access objects and add/remove entries. Commit the changes.
277+
278+ >>> for stage,blob in index.iter_blobs(): do_something(... )
279+ Access blob objects
280+ >>> for (path,stage),entry in index.entries.iteritems: pass
281+ Access the entries directly
282+ >>> index.add([' my_new_file' ]) # add a new file to the index
283+ >>> index.remove([' dir/existing_file' ])
284+ >>> new_commit = index.commit(" my commit message" )
285+
286+ Create new indices from other trees or as result of a merge. Write that result to
287+ a new index.
288+
289+ >>> tmp_index = Index.from_tree(repo, ' HEAD~1' ) # load a tree into a temporary index
290+ >>> merge_index = Index.from_tree(repo, ' HEAD' , ' some_branch' ) # merge two trees
291+ >>> merge_index.write(" merged_index" )
292+
244293Handling Remotes
245294****************
246295
296+ Remotes are used as alias for a foreign repository to ease pushing to and fetching
297+ from them.
298+
299+ >>> test_remote = repo.create_remote(' test' , ' git@server:repo.git' )
300+ >>> repo.delete_remote(test_remote) # create and delete remotes
301+ >>> origin = repo.remotes.origin # get default remote by name
302+ >>> origin.refs # local remote references
303+ >>> o = origin.rename(' new_origin' ) # rename remotes
304+ >>> o.fetch() # fetch, pull and push from and to the remote
305+ >>> o.pull()
306+ >>> o.push()
307+
308+ You can easily access configuration information for a remote by accessing options
309+ as if they where attributes.
310+
311+ >>> o.url
312+ 'git@server:dummy_repo.git'
313+
314+ Change configuration for a specific remote only
315+ >>> o.config_writer.set(" url" , " other_url" )
316+
247317Obtaining Diff Information
248318**************************
249319
0 commit comments