git-commit-tree - Linux


Overview

git-commit-tree creates a new commit object using the specified tree object and commit metadata. It takes the current HEAD as the parent and defaults the author to the current user.

Syntax

git commit-tree <tree-ish> [(-F | -m) <commit-message>]

Options/Flags

  • -F <file>: Read the commit message from the specified file.
  • -m <commit-message>: Specify the commit message directly on the command line.

Examples

Create a new commit using the current HEAD as the parent:

git commit-tree HEAD -m "New commit"

Create a new commit with a custom commit message:

git commit-tree HEAD -m "Custom commit message"

Create a new commit and read the commit message from a file:

git commit-tree HEAD -F commit-message.txt

Common Issues

  • Error: No message provided. Use the -m option to specify a commit message.

    • Ensure you provide a commit message using the -m option or redirect a file containing the message via -F.
  • Error: Tree not found.

    • Verify the specified <tree-ish> is a valid tree object in the repository.

Integration

Combine with git-read-tree to create a new commit from a custom tree:

git read-tree -u HEAD
git commit-tree -m "Custom commit tree"

Related Commands