Updated Edit
On this page
stage and commit specified files in a single atomic operation
#safegit commit
stage and commit specified files in a single atomic operation
Effect: mutating
#Flags
| Name | Short | Type | Presence | Env | Description |
|---|---|---|---|---|---|
--m | -m | list[str] | optional | commit message paragraph; repeating it joins the values with a blank line between them, so the first is the subject and the rest are the body | |
--F | -F | str | optional | read the full commit message body from a file instead of --m flags | |
--branch | str | optional | commit the staged files onto a different branch without switching to it | ||
--amend, --no-amend | bool | optional | amend the current HEAD commit by replacing it with updated content; omitted means a new commit | ||
--allow-empty, --no-allow-empty | bool | optional | allow creating a commit even when no files have been changed; omitted means an empty commit is refused | ||
--allow-non-portable-targets, --no-allow-non-portable-targets | bool | optional | record a symlink whose target text will not resolve in another checkout -- an absolute target, or a relative one resolving outside the repository -- which the commit stores as the link text; omitted, and with --no-allow-non-portable-targets, such a link is refused with its target named, because elsewhere it resolves to nothing or to a file the repository never carried | ||
--trailer | list[str] | optional | add a key-value trailer line to the commit message (repeatable) | ||
--hunks | list[str] (unique) | optional | commit only the selected hunks of one file, as 'path:1,3' or 'path:2-4' (the split is on the last colon, so a path containing colons stays intact); repeatable, once per path; omitted means every named file is committed whole | ||
--untrack | list[str] (unique) | optional | stop tracking a path, leaving the file itself on disk: the commit records its removal from the index (repeatable, one path each); the path must be tracked in the commit's parent; omitted means nothing is untracked | ||
--moved | list[str] (unique) | optional | declare that content moved, as 'old -> new' (repeatable, one pair each). End BOTH paths with a slash to declare a whole subtree. Quote a path C-style when it holds a space, a quote, a backslash or the arrow itself. The old path must be tracked in the commit's parent and gone from disk, and the new one must exist -- and the COMMIT ITSELF must bear the move out, carrying the new path in its tree and no longer carrying the old one, which means naming both paths among the files to commit. A declaration also SUPPRESSES safegit's own reading of the delta for the paths it names, and supersedes a record safegit already minted for the same pair on the commit an --amend replaces. Omitted means the commit declares no moves of its own, and safegit still records the ones its delta witnesses on its own | ||
--moved-retract | list[str] (unique) | optional | retract a move record declared earlier in this branch's history, by its id -- the token a 'Moved:' trailer begins with (repeatable, one id each). The id must name a record that exists and is not already retracted in the history this commit is built on; one that does not is refused rather than written. To write an unchecked retraction, use --trailer 'Moved-Retract: |
#Arguments
| Name | Type | Presence | Description |
|---|---|---|---|
files | list[str] (variadic) | optional | files to commit, taken literally -- a colon in an argument is part of the filename, and hunk selection is --hunks |
#Grants
| Kind | Name | Reason |
|---|---|---|
| proc_mutate | parent-bump | committing in a submodule moves the parent's gitlink, so safegit commits the parent too when commit.autoBumpParent is on |