fastgit0.0.4
fastgit0.0.4
Published
Use git from python, fast
pip install fastgit
Package Downloads
Authors
Project URLs
Requires Python
>=3.9
Dependencies
No dependencies
fastgit
Usage
Installation
Install latest from pypi
$ pip install fastgit
How to use
In this example we run git init on a directory, add a .gitignore,
and commit it.
import shutil, tempfile
def _git_init(g):
if g.exists: return # Return early if git already initialised
g.init(b='main')
g.config('user.name', 'fastgit')
g.config('user.email', '[email protected]')
(g.d/".gitignore").mk_write("*.bak")
g.add(".gitignore")
g.commit(m="add .gitignore")
td = tempfile.mkdtemp()
g = Git(td)
_git_init(g)
assert 'add .gitignore' in g.last_commit
print(g.branch('--show-current'))
main
You can also pass path arguments after -- using the __ parameter:
g.log('--oneline', __=['.gitignore'])
'22a9a5d add .gitignore'
shutil.rmtree(td)