Does anyone know what the equivalent of git commit -a
is in gitpython?
I have tried repo.index.commit
, but don't see how to add the -a option.
repo.index.add
adds only new files, not existing files that have been modified. It doesn't seem to support the update
function as in git add -u
.
I could do something like repo.git.commit('-a')
, or even
repo.git.add('-u')
repo.index.commit(comment)
But I would think the high-level interface should be capable of doing this. Am I missing something?
Thanks in advance,
Evert
To stage a file is simply to prepare it finely for a commit. Git, with its index allows you to commit only certain parts of the changes you've done since the last commit.
You are not missing anything. GitPython acts more like plumbing, not like the porcelain that is git add -u
and git commit
.
Therefore it is viable and recommended to use the provided git command wrapper to get work done quickly as already demonstrated in your example (e.g. repo.git.add(update=True)
).
Even though it is possible to implement anything purely in GitPython, it wouldn't perform as well or be as proven as the respective native git implementation already is.
GitPython starts to become powerful if you want to access git repository data quickly and conveniently through a relatively convenient and pythonic API. Examples include accessing branch and tag information, or querying commits in all detail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With