commit¶
-
async
_AsyncGit.commit(message: Optional[Union[str, bool]], *args, repo: Optional[str] = None) → str[source]¶ Calls
git commitwith the arguments-m "message" [args], where each positional argument passed after the message is passed as a command line argument.To disable prepending
-mto the arguments, passNoneas themessageand only your specifiedargswill be passed along togit commit.You may also set
messagetoFalsewhich will callgit commit --allow-empty-message [args]instead of prepending-m.Basic Usage
Standard commit with a message, plus the argument ‘-a’:
>>> g = Git() >>> g.commit("added example.txt", "-a")
Pass
Noneas the message to disable prepending-mto the git arguments. For example, the following call commits the current staged changes, while re-using the commit message/author info/timestamp from the previous commit9e27d7233ac5bc59bc37c0572a401068fbd5e6be:>>> g.commit(None, "-C", "9e27d7233ac5bc59bc37c0572a401068fbd5e6be")
Pass
Falseas the message for an easy way to callgit commit --allow-empty-message, plus any additional arguments you might pass:>>> g.commit(False, '-a')
- Parameters
message (str|bool) – The git commit message to commit with. Alternatively
Noneto remove the default-m, orFalseas a shortcut for--allow-empty-messageinstead of-m.args – Additional CLI arguments to pass to
git commitrepo (str) – (as a kwarg only!) An absolute path to a Git repository to run
git commitwithin. By default, this isNonewhich results in the repo passed in the constructor (repo) being used.
- Return str stdout
The string text printed to stdout by
git commitwhile running the command.