{"id":13495282,"url":"https://github.com/FriendCode/gittle","last_synced_at":"2025-03-28T16:32:08.363Z","repository":{"id":57434865,"uuid":"11192524","full_name":"FriendCode/gittle","owner":"FriendCode","description":"Pythonic Git for Humans","archived":false,"fork":false,"pushed_at":"2017-08-18T12:12:24.000Z","size":268,"stargazers_count":732,"open_issues_count":48,"forks_count":90,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-10-02T07:21:11.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FriendCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-05T05:48:10.000Z","updated_at":"2024-08-22T21:48:33.000Z","dependencies_parsed_at":"2022-09-04T15:25:04.854Z","dependency_job_id":null,"html_url":"https://github.com/FriendCode/gittle","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendCode%2Fgittle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendCode%2Fgittle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendCode%2Fgittle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FriendCode%2Fgittle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FriendCode","download_url":"https://codeload.github.com/FriendCode/gittle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222395794,"owners_count":16977624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:01:33.161Z","updated_at":"2024-10-31T10:30:53.384Z","avatar_url":"https://github.com/FriendCode.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Gittle - Pythonic Git for Humans\n\nGittle is a high-level pure-python git library.\nIt builds upon dulwich which provides most of the low-level machinery\n\n## Install it\n\n    pip install gittle\n\n## Examples :\n\n### Clone a repository\n\n```python\nfrom gittle import Gittle\n\nrepo_path = '/tmp/gittle_bare'\nrepo_url = 'git://github.com/FriendCode/gittle.git'\n\nrepo = Gittle.clone(repo_url, repo_path)\n```\n\nWith authentication (see Authentication section for more information) :\n\n```python\nauth = GittleAuth(pkey=key)\nGittle.clone(repo_url, repo_path, auth=auth)\n```\n\nOr clone bare repository (no working directory) :\n\n```python\nrepo = Gittle.clone(repo_url, repo_path, bare=True)\n```\n\n### Init repository from a path\n\n```python\nrepo = Gittle.init(path)\n```\n\n### Get repository information\n\n```python\n# Get list of objects\nrepo.commits\n\n# Get list of branches\nrepo.branches\n\n# Get list of modified files (in current working directory)\nrepo.modified_files\n\n# Get diff between latest commits\nrepo.diff('HEAD', 'HEAD~1')\n```\n\n### Commit\n\n```python\n# Stage single file\nrepo.stage('file.txt')\n\n# Stage multiple files\nrepo.stage(['other1.txt', 'other2.txt'])\n\n# Do the commit\nrepo.commit(name=\"Samy Pesse\", email=\"samy@friendco.de\", message=\"This is a commit\")\n```\n\n### Pull\n\n```python\nrepo = Gittle(repo_path, origin_uri=repo_url)\n\n# Authentication with RSA private key\nkey_file = open('/Users/Me/keys/rsa/private_rsa')\nrepo.auth(pkey=key_file)\n\n# Do pull\nrepo.pull()\n```\n\n### Push\n\n```python\nrepo = Gittle(repo_path, origin_uri=repo_url)\n\n# Authentication with RSA private key\nkey_file = open('/Users/Me/keys/rsa/private_rsa')\nrepo.auth(pkey=key_file)\n\n# Do push\nrepo.push()\n```\n\n### Authentication for remote operations\n\n```python\n# With a key\nkey_file = open('/Users/Me/keys/rsa/private_rsa')\nrepo.auth(pkey=key_file)\n\n# With username and password\nrepo.auth(username=\"your_name\", password=\"your_password\")\n```\n\n### Branch\n\n```python\n# Create branch off master\nrepo.create_branch('dev', 'master')\n\n# Checkout the branch\nrepo.switch_branch('dev')\n\n# Create an empty branch (like 'git checkout --orphan')\nrepo.create_orphan_branch('NewBranchName')\n\n# Print a list of branches\nprint(repo.branches)\n\n# Remove a branch\nrepo.remove_branch('dev')\n\n# Print a list of branches\nprint(repo.branches)\n```\n\n### Get file version\n\n```python\nversions = repo.get_file_versions('gittle/gittle.py')\nprint(\"Found %d versions out of a total of %d commits\" % (len(versions), repo.commit_count()))\n```\n\n### Get list of modified files (in current working directory)\n\n```python\nrepo.modified_files\n```\n\n### Count number of commits\n\n```python\nrepo.commit_count\n```\n\n### Get information for commits\n\nList commits :\n\n```python\n# Get 20 first commits\nrepo.commit_info(start=0, end=20)\n```\n\nWith a given commit :\n\n```python\ncommit = \"a2105a0d528bf770021de874baf72ce36f6c3ccc\"\n```\n\nDiff with another commit :\n\n```python\nold_commit = repo.get_previous_commit(commit, n=1)\nprint repo.diff(commit, old_commit)\n```\n\nExplore commit files using :\n\n```python\ncommit = \"a2105a0d528bf770021de874baf72ce36f6c3ccc\"\n\n# Files tree\nprint repo.commit_tree(commit)\n\n# List files in a subpath\nprint repo.commit_ls(commit, \"testdir\")\n\n# Read a file\nprint repo.commit_file(commit, \"testdir/test.txt\")\n```\n\n### Create a GIT server\n\n```python\nfrom gittle import GitServer\n\n# Read only\nGitServer('/', 'localhost').serve_forever()\n\n# Read/Write\nGitServer('/', 'localhost', perm='rw').serve_forever()\n```\n\n## Why implement Git in Python ?\n\n### NEED FOR AWESOMENESS :\n- Git is Awesome\n- Python is Awesome\n- Automating Git isn't so Awesome\n\n### TO SOLVE MY OWN PROBLEMS AT FRIENDCODE :\n- Automate git repo management (push/pull, commit, etc ...)\n- Scriptable and usable from Python\n- Easy to use \u0026 good interoperability in a SOA environment\n\n### USE IT FOR :\n- Local\n  - [X] Common git operations (add, rm, mv, commit, log)\n  - [X] Branch operations (creating, switching, deleting)\n- Remote\n  - [X] Fetching\n  - [X] Pushing\n  - [X] Pulling (needs merging)\n- Merging\n  - [-] Fast forward\n  - [-] Recursive\n  - [-] Merge branches\n- Diff\n  - [X] Filter binary files\n\n# Building and uploading to PyPi\n\n```\npython setup.py sdist bdist_egg upload\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFriendCode%2Fgittle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFriendCode%2Fgittle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFriendCode%2Fgittle/lists"}