-
-
Notifications
You must be signed in to change notification settings - Fork 937
WIP Quick doc #1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
WIP Quick doc #1608
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
97cdb40
Made the init repo section of quickdoc
LeoDaCoda 6a9154b
Added git clone & git add
LeoDaCoda 3c42bae
Finishing touches for Repo quickstart
LeoDaCoda 10ea113
finished code for quickstart
LeoDaCoda b0da0a9
finished code for quickstart
LeoDaCoda fb35ed1
fixed some indentation
LeoDaCoda d42d82e
Merge remote-tracking branch 'origin/quick_doc' into quick_doc
LeoDaCoda 47c8362
added quickstart to toctree and fixed sphinx warning
LeoDaCoda b7955ed
added quickstart to toctree to fix sphinx warning
LeoDaCoda 4534f84
Merge remote-tracking branch 'origin/quick_doc' into quick_doc
LeoDaCoda 03d26f0
Removed code from RST
LeoDaCoda a0045d8
Made variable names more intuitive
LeoDaCoda 9833655
Updated the sample repo URL
LeoDaCoda 3cda530
removed try/except and updated sample url
LeoDaCoda e4bbc7a
correct way to get the latest commit tree
LeoDaCoda a1dfd4a
convert from --all flag to all=True
LeoDaCoda a8b5863
removed unnecessary variables
LeoDaCoda abe7e6e
replaced output cell to generic commit ID
LeoDaCoda 1369bdc
replaced hash with generic
LeoDaCoda 9cd9431
draft of description
LeoDaCoda 393bae5
clarified comment
LeoDaCoda aa6d27f
refactored print git tree
LeoDaCoda 6d78ff1
Made trees and blobs the first section
LeoDaCoda 2c9c0c1
Added warning about index add
LeoDaCoda d276107
Updated generic sha hash
LeoDaCoda f3968f2
Removed all reference to source code
LeoDaCoda 9ca25d7
WIP major changes to structure to improve readability
LeoDaCoda 7fa57e5
Added new section to print prev file
LeoDaCoda 9d878af
change to formatting - removed = bash cmds
LeoDaCoda 315405d
formatting wip
LeoDaCoda bccf8bc
added new section for diffs and formatting
LeoDaCoda cad1e2e
tabbed all code-blocks
LeoDaCoda 7e589f3
fixed tabbing
LeoDaCoda 2a45f94
redundant line
LeoDaCoda ef4d6d5
redundant code cell
LeoDaCoda 8138b3a
generic hash
LeoDaCoda 84885a3
added more resources section
LeoDaCoda cf3a899
typo
LeoDaCoda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ GitPython Documentation | |
:maxdepth: 2 | ||
|
||
intro | ||
quickstart | ||
tutorial | ||
reference | ||
roadmap | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
.. _quickdoc_toplevel: | ||
|
||
.. highlight:: python | ||
|
||
.. _quickdoc-label: | ||
|
||
============================== | ||
GitPython Quick Start Tutorial | ||
============================== | ||
Welcome to the GitPython Quickstart Guide! Designed for developers seeking a practical and interactive learning experience, this concise resource offers step-by-step code snippets to swiftly initialize/clone repositories, perform essential Git operations, and explore GitPython's capabilities. Get ready to dive in, experiment, and unleash the power of GitPython in your projects! | ||
|
||
|
||
Byron marked this conversation as resolved.
Show resolved
Hide resolved
|
||
git.Repo | ||
******** | ||
|
||
There are a few ways to create a :class:`git.Repo <git.repo.base.Repo>` object | ||
|
||
Initialize a new git Repo | ||
######################### | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [1-test_init_repo_object] | ||
:end-before: # ![1-test_init_repo_object] | ||
|
||
Existing local git Repo | ||
####################### | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [2-test_init_repo_object] | ||
:end-before: # ![2-test_init_repo_object] | ||
|
||
Clone from URL | ||
############## | ||
|
||
For the rest of this tutorial we will use a clone from https://github.com/gitpython-developers/QuickStartTutorialFiles.git | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [1-test_cloned_repo_object] | ||
:end-before: # ![1-test_cloned_repo_object] | ||
|
||
|
||
Trees & Blobs | ||
************** | ||
|
||
Latest Commit Tree | ||
################## | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [12-test_cloned_repo_object] | ||
:end-before: # ![12-test_cloned_repo_object] | ||
|
||
Any Commit Tree | ||
############### | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [13-test_cloned_repo_object] | ||
:end-before: # ![13-test_cloned_repo_object] | ||
|
||
Display level 1 Contents | ||
######################## | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [14-test_cloned_repo_object] | ||
:end-before: # ![14-test_cloned_repo_object] | ||
|
||
Recurse through the Tree | ||
######################## | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [15-test_cloned_repo_object] | ||
:end-before: # ![15-test_cloned_repo_object] | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [16-test_cloned_repo_object] | ||
:end-before: # ![16-test_cloned_repo_object] | ||
|
||
|
||
|
||
|
||
Usage | ||
**************** | ||
|
||
Add file to staging area | ||
######################## | ||
|
||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [2-test_cloned_repo_object] | ||
:end-before: # ![2-test_cloned_repo_object] | ||
|
||
Now lets add the updated file to git | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [3-test_cloned_repo_object] | ||
:end-before: # ![3-test_cloned_repo_object] | ||
|
||
Notice the add method requires a list as a parameter | ||
|
||
Warning: If you experience any trouble with this, try to invoke :class:`git <git.cmd.Git>` instead via repo.git.add(path) | ||
|
||
Commit | ||
###### | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [4-test_cloned_repo_object] | ||
:end-before: # ![4-test_cloned_repo_object] | ||
|
||
List of commits associated with a file | ||
####################################### | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [5-test_cloned_repo_object] | ||
:end-before: # ![5-test_cloned_repo_object] | ||
|
||
Notice this returns a generator object | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [6-test_cloned_repo_object] | ||
:end-before: # ![6-test_cloned_repo_object] | ||
|
||
returns list of :class:`Commit <git.objects.commit.Commit>` objects | ||
|
||
Printing text files | ||
#################### | ||
Lets print the latest version of `<local_dir>/dir1/file2.txt` | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [17-test_cloned_repo_object] | ||
:end-before: # ![17-test_cloned_repo_object] | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [18-test_cloned_repo_object] | ||
:end-before: # ![18-test_cloned_repo_object] | ||
|
||
Previous version of `<local_dir>/dir1/file2.txt` | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [18.1-test_cloned_repo_object] | ||
:end-before: # ![18.1-test_cloned_repo_object] | ||
|
||
Status | ||
###### | ||
* Untracked files | ||
|
||
Lets create a new file | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [7-test_cloned_repo_object] | ||
:end-before: # ![7-test_cloned_repo_object] | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [8-test_cloned_repo_object] | ||
:end-before: # ![8-test_cloned_repo_object] | ||
|
||
* Modified files | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [9-test_cloned_repo_object] | ||
:end-before: # ![9-test_cloned_repo_object] | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [10-test_cloned_repo_object] | ||
:end-before: # ![10-test_cloned_repo_object] | ||
|
||
returns a list of :class:`Diff <git.diff.Diff>` objects | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [11-test_cloned_repo_object] | ||
:end-before: # ![11-test_cloned_repo_object] | ||
|
||
Diffs | ||
###### | ||
|
||
Compare staging area to head commit | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [11.1-test_cloned_repo_object] | ||
:end-before: # ![11.1-test_cloned_repo_object] | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [11.2-test_cloned_repo_object] | ||
:end-before: # ![11.2-test_cloned_repo_object] | ||
|
||
Compare commit to commit | ||
|
||
.. literalinclude:: ../../test/test_quick_doc.py | ||
:language: python | ||
:dedent: 8 | ||
:start-after: # [11.3-test_cloned_repo_object] | ||
:end-before: # ![11.3-test_cloned_repo_object] | ||
|
||
|
||
More Resources | ||
**************** | ||
|
||
Remember, this is just the beginning! There's a lot more you can achieve with GitPython in your development workflow. | ||
To explore further possibilities and discover advanced features, check out the full :ref:`GitPython tutorial <tutorial_toplevel>` | ||
and the :ref:`API Reference <api_reference_toplevel>`. Happy coding! |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.