grgit-commit - Record changes to the repository


grgit.commit(message: <message>, paths: [<path>, ...], all: <boolean>, amend: <boolean>,
  reflogComment: <message>, committer: <person>, author: <person>)
grgit.commit {
  message = <message>
  paths = [<path>, ...]
  all = <boolean>
  amend = <boolean>
  reflogComment = <message>
  committer = <person>
  author = <person>


Stores the current contents of the index in a new commit along with a log message from the user describing the changes.

The content to be added can be specified in several ways:

  1. by using grgit-add to incrementally "add" changes to the index before using the commit command (Note: even modified files must be "added");

  2. by using grgit-remove to remove files from the working tree and the index, again before using the commit command;

  3. by listing paths as arguments to the commit command, in which case the commit will ignore changes staged in the index, and instead record the current content of the listed files (which must already be known to Git);

  4. by using the all switch with the commit command to automatically "add" changes from all known files (i.e. all files that are already listed in the index) and to automatically "rm" files in the index that have been removed from the working tree, and then perform the actual commit;

If you make a commit and then find a mistake immediately after that, you can recover from it with grgit-reset.

Returns a Commit representing the new HEAD.



(String, default null) Use the given <msg> as the commit message.


(Set<String>, default []) When files are given on the command line, the command commits the contents of the named files, without recording the changes already staged. The contents of these files are also staged for the next commit on top of what have been staged before.


(boolean, default false) Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected.


(boolean, default false) Replace the tip of the current branch by creating a new commit. The recorded tree is prepared as usual, and the message from the original commit is used as the starting point, instead of an empty message, when no other message is specified from the command line. The new commit has the same parents and author as the current one.


(String, default null) Use a different comment in the reflog for this commit.


(Person, default null) Override the committer recorded in the commit. This must be a Person.


(Person, default null) Override the author recorded in the commit. This must be a Person.


To commit all staged changes.

def commit = grgit.commit(message: 'something about the change')

To commit changes to all previously tracked files.

def commit = grgit.commit(message: 'something about the change', all: true)

To amend the previous commit.

def commit = grgit.commit(message: 'something about the change', amend: true)

To commit changes authored by another person.

def commit = grgit.commit(message: 'something about the change', author: new Person('Bruce Wayne', ''))

See Also