Git Extended icon

Git Extended

Run Git commands

Overview

The node "Git Extended" allows running various Git commands directly from n8n workflows by executing Git CLI commands on a specified local repository path. It supports a wide range of Git operations such as cloning repositories, committing changes, managing branches, pushing and pulling from remotes, resetting commits, reverting commits, applying patches, and more.

This node is beneficial in automation scenarios where you want to integrate Git version control actions into your workflow without manually running Git commands. For example, it can be used to automate deployment pipelines, synchronize code repositories, manage feature branches, or revert problematic commits programmatically.

Specifically, the Reset operation resets the current HEAD to a specified commit hash (or to the latest commit if no hash is provided) using a hard reset, effectively discarding all changes after that commit in the working directory and index.

Properties

Name Meaning
Repository Path Filesystem path to run the Git command from. For clone, the repository will be created inside this path.
Commit ID Commit hash to reset to. If empty, resets to the current HEAD.
Skip Stdout Whether to ignore the command output to avoid maxBuffer errors.

Output

The node outputs JSON data containing the standard output (stdout) and standard error (stderr) strings returned by the executed Git command, trimmed of whitespace. If the Skip Stdout option is enabled, the output JSON will be empty since the command output is ignored to prevent buffer overflow issues.

Example output when not skipping stdout:

{
  "stdout": "<git command output>",
  "stderr": "<git command error output>"
}

If an error occurs during execution and the node is configured to continue on failure, the output will contain an error field with the error message.

The node does not output binary data.

Dependencies

  • Requires Git to be installed and accessible via the command line on the machine where n8n runs.
  • Uses Node.js child process utilities to execute Git commands.
  • Requires an API key credential for authentication when performing operations that interact with remote repositories (e.g., clone, push, pull), but the Reset operation itself works locally and does not require authentication.
  • No additional external services are required for the Reset operation.

Troubleshooting

  • Common Issues:

    • Invalid or non-existent repository path: The node expects a valid local Git repository path. Ensure the path exists and contains a Git repo.
    • Invalid commit hash: Providing an incorrect or non-existent commit ID will cause Git to fail the reset command.
    • Permission issues: The user running n8n must have filesystem permissions to access and modify the repository directory.
    • Buffer overflow errors: Large command outputs may cause maxBuffer errors; enable Skip Stdout to mitigate this.
  • Error Messages:

    • "Unsupported operation reset": Indicates the operation name was not recognized; ensure the operation parameter is set correctly.
    • "Command failed with exit code X": Generic error indicating the Git command failed; check the stderr output for details.
    • "Commit ID is required": For operations like cherry-pick or revert, but not applicable to reset if commit is optional.
  • Resolutions:

    • Verify the repository path and commit hash inputs.
    • Use the Skip Stdout option if encountering buffer size errors.
    • Check file system permissions.
    • Review the Git command output in the node's output for specific Git errors.

Links and References

Discussion