Skip to main content

fastgit

fastgit is a thin Python wrapper for the git CLI: one Git object whose attribute calls run git commands, so if you know git, you already know fastgit. There is no reimplementation of git internals and no object model to learn – commands return git’s own output as (subclassed) strs.

It is designed for interactive use and automation alike: errors print tersely by default (like git itself) or raise on request, exit codes that mean “no” rather than “failed” are returned normally, and passing sync=False gives an async client for servers and concurrent code.

Usage

Installation

Install latest from pypi

$ pip install fastgit

How to use

Create a Git for any directory; every command runs with that directory as its working tree. Method names map to git subcommands, and results come back as stripped strings:

import shutil, tempfile
td = tempfile.mkdtemp()
g = Git(td)
g.init(b='main')
'Initialized empty Git repository in /private/var/folders/51/b2_szf2945n072c0vj2cyty40000gn/T/tmp8zyj76q7/.git/'
(g.d/'.gitignore').mk_write('*.bak')
g.add('.gitignore')
g.commit(m='add .gitignore')
'[main (root-commit) 5113ce1] add .gitignore\n 1 file changed, 1 insertion(+)\n create mode 100644 .gitignore'

Keyword arguments become options: single-letter names are short options (n=1-n 1), longer names long options with underscores turned into dashes, and True passes the bare flag:

g.log(n=1, oneline=True)
'5113ce1 add .gitignore'

You can also pass path arguments after -- using the __ parameter:

g.log('--oneline', __=['.gitignore'])
'5113ce1 add .gitignore'

Frequent queries are properties:

g.current_branch, g.commits
('main', ['5113ce1 add .gitignore'])

A failed command prints git’s message and returns None; pass raise_exc=True (per call or at init) to raise instead. Where git uses exit 1 to mean “no” rather than “error” – like grep finding nothing – the output is returned as usual, with the code on .returncode:

res = g.grep('missing')
res.returncode
1

Pass sync=False for an async client: the same commands and properties, each returning an awaitable, so a server never blocks its event loop on git:

ag = Git(td, sync=False)
await ag.last_commit
'add .gitignore'

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastgit-0.1.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastgit-0.1.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file fastgit-0.1.2.tar.gz.

File metadata

  • Download URL: fastgit-0.1.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for fastgit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0a37a033b2d458e0f2839692ee549a9ffa1bdc1d61527af5dfc1e3a00ebfc814
MD5 d31ba003b44b3f6557b1d60a58f76781
BLAKE2b-256 40e4929fc011d8ed75e90cac67459707daf21dbe1037b2eafa3f6991563f6e93

See more details on using hashes here.

File details

Details for the file fastgit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fastgit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for fastgit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 990ce2843779d6353671d60d3276cb0b2d25278172d3d4902e90925a70d741f6
MD5 95991505cc235c1a003c6a798f10c60c
BLAKE2b-256 668f70609f5b458842b947a2b08890f486f1adc914b66b4728a7faa5db4bd425

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page