Git Extended icon

Git Extended

Run Git commands

Overview

This node allows users to run various Git commands directly from n8n workflows. It supports common Git operations such as adding files, cloning repositories, committing changes, pushing and pulling branches, checking status, switching branches, merging, and more. This node is beneficial for automating version control tasks within CI/CD pipelines, synchronizing code repositories, or managing Git repositories programmatically without leaving the workflow environment.

For example, you can use this node to:

  • Add specific files to staging before a commit.
  • Clone a remote repository into a specified directory.
  • Commit changes with a custom message.
  • Push commits to a remote branch.
  • Pull updates from a remote branch.
  • Switch between branches or merge branches.

Properties

Name Meaning
Repository Path Filesystem path where the Git command will be executed. For clone, the repository is created inside this path.
Files Files or patterns to add to the staging area (used only in the "Add" operation).

Output

The node outputs JSON data containing the results of the executed Git command:

  • stdout: The standard output from the Git command, typically containing success messages or command results.
  • stderr: The standard error output from the Git command, which may include warnings or error messages.

No binary data is produced by this node.

Example output JSON structure:

{
  "stdout": "On branch main\nnothing to commit, working tree clean",
  "stderr": ""
}

Dependencies

  • Requires Git to be installed and accessible on the system where n8n is running.
  • No external API keys or credentials are needed since it operates on local Git repositories via command line.
  • The node uses Node.js child process execution to run Git commands.

Troubleshooting

  • Common issues:

    • Incorrect Repository Path may cause errors if the path does not exist or is not a Git repository (except for clone/init operations).
    • Invalid file patterns in the "Add" operation might result in no files being staged.
    • Insufficient permissions to access the filesystem path or execute Git commands.
    • Conflicts during merge or checkout operations that require manual resolution.
  • Error messages:

    • Errors from Git commands are captured in the stderr output field.
    • If an unsupported operation is selected, the node throws an error indicating the operation is unsupported.
    • If the node fails and "Continue On Fail" is enabled, the error message is included in the output JSON under the error key.

To resolve errors:

  • Verify the correctness of all input parameters.
  • Ensure the target paths exist and have proper permissions.
  • Check that Git is properly installed and configured on the host machine.
  • Review the stderr output for detailed Git error messages.

Links and References

Discussion