Git Extended icon

Git Extended

Run Git commands

Overview

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

For example, you can use this node to:

  • Clone a repository into a specified directory.
  • Add specific files to the staging area.
  • 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 new repository is created inside this path.
Operation The Git operation to perform. Options include: Add, Checkout, Clone, Commit, Init, Log, Merge, Pull, Push, Status, Switch Branch.
Repository URL (For Clone operation) The URL of the Git repository to clone.
Target Path (For Clone operation) Directory path where the repository will be cloned into.
Files (For Add operation) Files or patterns to add to the staging area.
Commit Message (For Commit operation) The commit message describing the changes.
Remote (For Push and Pull operations) The name of the remote repository, e.g., "origin".
Branch (For Push and Pull operations) The branch name to push to or pull from.
Target (For Switch, Checkout, Merge operations) The branch or commit to operate on.

Output

The node outputs JSON data containing two main fields:

  • stdout: The standard output from the executed Git command, trimmed of whitespace.
  • stderr: The standard error output from the Git command, trimmed of whitespace.

This output provides the result or feedback from the Git operation performed. There is no binary data output.

Example output JSON structure:

{
  "stdout": "On branch main\nYour branch is up to date with 'origin/main'.",
  "stderr": ""
}

Dependencies

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

Troubleshooting

  • Common issues:

    • Incorrect repository paths may cause errors like "fatal: not a git repository".
    • Missing or incorrect branch names can lead to checkout or merge failures.
    • Insufficient permissions on the filesystem can prevent Git commands from executing.
    • If the Git executable is not found, commands will fail.
  • 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.
    • To handle errors gracefully, enable "Continue On Fail" in the node settings to capture errors per item without stopping the workflow.
  • Resolution tips:

    • Verify that the repository path exists and is a valid Git repository (except for clone/init).
    • Ensure branch and remote names are correct and exist.
    • Check file system permissions for the user running n8n.
    • Confirm Git is installed and available in the system PATH.

Links and References

Discussion