You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/tutorial.rst
+79-18
Original file line number
Diff line number
Diff line change
@@ -55,26 +55,67 @@ Archive the repository contents to a tar file.
55
55
:start-after: # [6-test_init_repo_object]
56
56
:end-before: # ![6-test_init_repo_object]
57
57
58
-
.. todo repo paths, heads, remotes, submodules
59
-
60
-
61
-
Object Databases
62
-
****************
63
-
``Repo`` instances are powered by its object database instance which will be used when extracting any data, or when writing new objects.
58
+
Advanced Repo Usage
59
+
===================
64
60
65
-
The type of the database determines certain performance characteristics, such as the quantity of objects that can be read per second, the resource usage when reading large data files, as well as the average memory footprint of your application.
61
+
And of course, there is much more you can do with this type, most of the following will be explained in greater detail in specific tutorials.
66
62
67
-
GitDB
68
-
=====
69
-
The GitDB is a pure-python implementation of the git object database. It is the default database to use in GitPython 0.3. Its uses less memory when handling huge files, but will be 2 to 5 times slower when extracting large quantities small of objects from densely packed repositories::
70
-
71
-
repo = Repo("path/to/repo", odbt=GitDB)
63
+
Query relevant repository paths ...
64
+
65
+
.. literalinclude:: ../../git/test/test_docs.py
66
+
:language: python
67
+
:start-after: # [7-test_init_repo_object]
68
+
:end-before: # ![7-test_init_repo_object]
69
+
70
+
:class:`Heads <git.refs.head.Head>` Heads are branches in git-speak. :class:`References <git.refs.reference.Reference>` are pointers to a specific commit or to other references. Heads and :class:`Tags <git.refs.tag.TagReference>` are a kind of references. GitPython allows you to query them rather intuitively.
71
+
72
+
.. literalinclude:: ../../git/test/test_docs.py
73
+
:language: python
74
+
:start-after: # [8-test_init_repo_object]
75
+
:end-before: # ![8-test_init_repo_object]
76
+
77
+
You can also create new heads ...
78
+
79
+
.. literalinclude:: ../../git/test/test_docs.py
80
+
:language: python
81
+
:start-after: # [9-test_init_repo_object]
82
+
:end-before: # ![9-test_init_repo_object]
83
+
84
+
... and tags ...
85
+
86
+
.. literalinclude:: ../../git/test/test_docs.py
87
+
:language: python
88
+
:start-after: # [10-test_init_repo_object]
89
+
:end-before: # ![10-test_init_repo_object]
90
+
91
+
You can traverse down to :class:`git objects <git.objects.base.Object>` through references and other objects. Some objects like :class:`commits <git.objects.commit.Commit>` have additional meta-data to query.
92
+
93
+
.. literalinclude:: ../../git/test/test_docs.py
94
+
:language: python
95
+
:start-after: # [11-test_init_repo_object]
96
+
:end-before: # ![11-test_init_repo_object]
97
+
98
+
:class:`Remotes <git.remote.Remote>` allow to handle fetch, pull and push operations, while providing optional real-time progress information to :class:`progress delegates <git.util.RemoteProgress>`.
99
+
100
+
.. literalinclude:: ../../git/test/test_docs.py
101
+
:language: python
102
+
:start-after: # [12-test_init_repo_object]
103
+
:end-before: # ![12-test_init_repo_object]
104
+
105
+
The :class:`index <git.index.base.IndexFile>` is also called stage in git-speak. It is used to prepare new commits, and can be used to keep results of merge operations. Our index implementation allows to stream date into the index, which is useful for bare repositories that do not have a working tree.
106
+
107
+
.. literalinclude:: ../../git/test/test_docs.py
108
+
:language: python
109
+
:start-after: # [13-test_init_repo_object]
110
+
:end-before: # ![13-test_init_repo_object]
111
+
112
+
:class:`Submodules <git.objects.submodule.Submodule>` represent all aspects of git submodules, which allows you query all of their related information, and manipulate in various ways.
113
+
114
+
.. literalinclude:: ../../git/test/test_docs.py
115
+
:language: python
116
+
:start-after: # [14-test_init_repo_object]
117
+
:end-before: # ![14-test_init_repo_object]
72
118
73
-
GitCmdObjectDB
74
-
==============
75
-
The git command database uses persistent git-cat-file instances to read repository information. These operate very fast under all conditions, but will consume additional memory for the process itself. When extracting large files, memory usage will be much higher than the one of the ``GitDB``::
76
-
77
-
repo = Repo("path/to/repo", odbt=GitCmdObjectDB)
78
119
79
120
Examining References
80
121
********************
@@ -107,7 +148,7 @@ Access the reflog easily::
107
148
log[0] # first (i.e. oldest) reflog entry
108
149
log[-1] # last (i.e. most recent) reflog entry
109
150
110
-
For more information on the reflog, see the ``RefLog`` type's documentation.
151
+
For more information on the reflog, see the :class:`git.RefLog <git.refs.log.RefLog>` type's documentation.
111
152
112
153
Modifying References
113
154
********************
@@ -454,6 +495,26 @@ The special notion ``git.command(flag=True)`` will create a flag without value l
454
495
455
496
If ``None`` is found in the arguments, it will be dropped silently. Lists and tuples passed as arguments will be unpacked recursively to individual arguments. Objects are converted to strings using the str(...) function.
456
497
498
+
499
+
Object Databases
500
+
****************
501
+
:class:`git.Repo <git.repo.base.Repo>` instances are powered by its object database instance which will be used when extracting any data, or when writing new objects.
502
+
503
+
The type of the database determines certain performance characteristics, such as the quantity of objects that can be read per second, the resource usage when reading large data files, as well as the average memory footprint of your application.
504
+
505
+
GitDB
506
+
=====
507
+
The GitDB is a pure-python implementation of the git object database. It is the default database to use in GitPython 0.3. Its uses less memory when handling huge files, but will be 2 to 5 times slower when extracting large quantities small of objects from densely packed repositories::
508
+
509
+
repo = Repo("path/to/repo", odbt=GitDB)
510
+
511
+
512
+
GitCmdObjectDB
513
+
==============
514
+
The git command database uses persistent git-cat-file instances to read repository information. These operate very fast under all conditions, but will consume additional memory for the process itself. When extracting large files, memory usage will be much higher than the one of the ``GitDB``::
0 commit comments