Class: Git::Commands::Commit Private
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
arguments block audited against https://git-scm.com/docs/git-commit/2.53.0
Implements the git commit command
This command records changes to the repository by creating a new commit with the staged changes.
Examples:
Typical usage
Typical usage
commit = Git::Commands::Commit.new(execution_context)
commit.call(message: 'Initial commit')
commit.call(message: 'Add feature', all: true, author: 'Jane <jane@example.com>')
commit.call(amend: true, no_verify: true) # emits --no-verify
commit.call('src/foo.rb', message: 'Update foo')
See Also:
Instance Method Summary collapse
-
#call(*pathspec, **options) ⇒ Git::CommandLineResult
Execute the
git commitcommand.
Methods inherited from Base
allow_exit_status, arguments, #initialize, requires_git_version, skip_version_validation
Constructor Details
This class inherits a constructor from Git::Commands::Base
Instance Method Details
#call(*pathspec, **options) ⇒ Git::CommandLineResult
Execute the git commit command.
Parameters:
-
pathspec
(Array<String>)
—
zero or more paths to commit
When given, only changes to the listed paths are committed, ignoring staged changes for other paths.
-
options
(Hash)
—
command options
Options Hash (**options):
-
:all
(Boolean, nil)
— default:
nil
—
automatically stage modified and deleted files before committing
Alias:
:a -
:edit
(Boolean, nil)
— default:
nil
—
open an editor for the commit message (
--edit)Alias:
:e -
:no_edit
(Boolean, nil)
— default:
nil
—
suppress the editor (
--no-edit) -
:amend
(Boolean, nil)
— default:
nil
—
replace the tip of the current branch with a new commit
-
:reuse_message
(String)
— default:
nil
—
reuse the log message and authorship from the given commit without invoking an editor
Alias:
:C -
:fixup
(String)
— default:
nil
—
create a fixup or amend commit targeting the given commit
Pass
<commit>for a plain "fixup!" commit,amend:<commit>to also replace the log message, orreword:<commit>to replace only the log message. -
:squash
(String)
— default:
nil
—
construct a "squash!" commit message for use with
git rebase --autosquash -
:message
(String)
— default:
nil
—
use the given string as the commit message
Alias:
:m -
:file
(String)
— default:
nil
—
read the commit message from the given file; use
-to read from standard inputAlias:
:F -
:template
(String)
— default:
nil
—
start the editor with the contents of the given file as the commit message template
Alias:
:t -
:reset_author
(Boolean, nil)
— default:
nil
—
when used with
:reuse_messageor:amend, declare the committer as the new author -
:author
(String)
— default:
nil
—
override the commit author
-
:date
(String)
— default:
nil
—
override the author date
-
:cleanup
(String)
— default:
nil
—
how to clean up the commit message before committing; one of
strip,whitespace,verbatim,scissors, ordefault -
:trailer
(String, Array<String>)
— default:
nil
—
add one or more
<token>[=<value>]trailers to the commit message -
:verify
(Boolean, nil)
— default:
nil
—
run pre-commit and commit-msg hooks (
--verify)Alias:
:n -
:no_verify
(Boolean, nil)
— default:
nil
—
bypass pre-commit and commit-msg hooks (
--no-verify) -
:allow_empty
(Boolean, nil)
— default:
nil
—
allow committing with no changes
-
:allow_empty_message
(Boolean, nil)
— default:
nil
—
allow committing with an empty message
-
:no_post_rewrite
(Boolean, nil)
— default:
nil
—
bypass the post-rewrite hook
-
:include
(Boolean, nil)
— default:
nil
—
stage the listed paths before committing in addition to already-staged contents
Alias:
:i -
:only
(Boolean, nil)
— default:
nil
—
commit only the listed paths from the working tree, ignoring staged changes for other paths
Alias:
:o -
:dry_run
(Boolean, nil)
— default:
nil
—
do not create a commit; show what would be committed
-
:short
(Boolean, nil)
— default:
nil
—
show short-format dry-run output; implies
:dry_run -
:branch
(Boolean, nil)
— default:
nil
—
show branch and tracking info in short-format dry-run output
-
:porcelain
(Boolean, nil)
— default:
nil
—
show porcelain-format dry-run output; implies
:dry_run -
:long
(Boolean, nil)
— default:
nil
—
show long-format dry-run output; implies
:dry_run -
:null
(Boolean, nil)
— default:
nil
—
terminate dry-run output entries with NUL instead of LF
Alias:
:z -
:verbose
(Boolean, Integer, nil)
— default:
nil
—
show unified diff between HEAD and what would be committed at the bottom of the commit message template
Pass
2to also show the unified diff between staged and working-tree changes.Alias:
:v -
:quiet
(Boolean, nil)
— default:
nil
—
suppress commit summary message
Alias:
:q -
:status
(Boolean, nil)
— default:
nil
—
include
git statusoutput in the commit message template (--status) -
:no_status
(Boolean, nil)
— default:
nil
—
omit
git statusoutput from the commit message template (--no-status) -
:unified
(Integer)
— default:
nil
—
generate verbose diff with the given number of context lines
Alias:
:U -
:inter_hunk_context
(Integer)
— default:
nil
—
show context between diff hunks up to the given number of lines (for use with
:verbose) -
:signoff
(Boolean, nil)
— default:
nil
—
add a
Signed-off-bytrailer to the commit message (--signoff)Alias:
:s -
:no_signoff
(Boolean, nil)
— default:
nil
—
suppress the
Signed-off-bytrailer (--no-signoff) -
:gpg_sign
(Boolean, String, nil)
— default:
nil
—
GPG-sign the commit (
--gpg-sign)When
true, uses the default key. When aString, uses the specified key ID.Alias:
:S -
:no_gpg_sign
(Boolean, nil)
— default:
nil
—
disable GPG signing, overriding
commit.gpgSignconfig (--no-gpg-sign) -
:untracked_files
(Boolean, String, nil)
— default:
nil
—
show untracked files in the dry-run status output
When
true, uses git's default mode (all). Pass aString("no","normal", or"all") to set the mode explicitly.Alias:
:u -
:pathspec_from_file
(String)
— default:
nil
—
read pathspec from the given file instead of the command line
-
:pathspec_file_nul
(Boolean, nil)
— default:
nil
—
pathspec elements in
:pathspec_from_fileare NUL-separated instead of newline-separated
Returns:
-
(Git::CommandLineResult)
—
the result of calling
git commit
Raises:
-
(ArgumentError)
—
if unsupported options are provided
-
(Git::FailedError)
—
if git exits with a non-zero exit status
|
|
# File 'lib/git/commands/commit.rb', line 96
|