diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-19 18:53:40 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-19 18:53:40 +0100 |
commit | e395ac90bf088ad6b5de7dadb6531a6e7f3f4f3f (patch) | |
tree | 7dcf36f94c9f5ca6ca22c2a70d68c9a0a7440ece /doc/source/tutorial.rst | |
parent | 048ffa58468521c043de567f620003457b8b3dbe (diff) | |
download | gitpython-e395ac90bf088ad6b5de7dadb6531a6e7f3f4f3f.tar.gz |
Added tutorial about initializing a repository.
Additionally, for this and future examples, there is a test_doc.py
suite to contain all code mentioned in the docs. That way, we know
if things stop working.
Fixes #236
Diffstat (limited to 'doc/source/tutorial.rst')
-rw-r--r-- | doc/source/tutorial.rst | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst index 3f45b70d..4921d07b 100644 --- a/doc/source/tutorial.rst +++ b/doc/source/tutorial.rst @@ -415,6 +415,22 @@ The previous approach would brutally overwrite the user's changes in the working repo.heads.master.checkout() # checkout the branch using git-checkout repo.heads.other_branch.checkout() +Initializing a repository +************************* + +In this example, we will initialize an empty repository, add an empty file to the index, and commit the change:: + + repo_dir = 'my-new-repo' + file_name = os.path.join(repo_dir, 'new-file') + + r = git.Repo.init(repo_dir) + # This function just creates an empty file ... + touch(file_name) + r.index.add([file_name]) + r.index.commit("initial commit") + +Please have a look at the individual methods as they usually support a vast amount of arguments to customize their behavior. + Using git directly ****************** In case you are missing functionality as it has not been wrapped, you may conveniently use the git command directly. It is owned by each repository instance:: |