Git Extended icon

Git Extended

Run Git commands

Overview

The node "Git Extended" allows users to run various Git commands directly from n8n workflows. It supports a wide range of Git operations such as cloning repositories, checking out branches or commits, merging branches, committing changes, pushing and pulling from remotes, managing branches and tags, applying patches, and more.

For the Checkout operation specifically, the node switches the working directory to a specified branch or commit within a local Git repository. This is useful when you want to automate workflows that depend on switching code contexts, for example:

  • Automatically switching to a feature branch before running tests.
  • Checking out a specific commit to build or deploy an older version.
  • Switching between branches in CI/CD pipelines.

Properties

Name Meaning
Repository Path Filesystem path where the Git command will be executed. For checkout, this is the local repo path. Default is ".".
Target The branch name or commit hash to check out. This is required.
Skip Stdout Whether to ignore the command output (stdout) to avoid buffer overflow errors. Defaults to false.

Output

The node outputs JSON data containing the standard output (stdout) and standard error (stderr) strings returned by the Git command execution, unless Skip Stdout is enabled. In that case, the output JSON will be empty.

Example output JSON when not skipping stdout:

{
  "stdout": "Switched to branch 'feature-branch'",
  "stderr": ""
}

If Skip Stdout is true, the output JSON will be:

{}

No binary data output is produced by this operation.

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 a valid local Git repository at the specified Repository Path.
  • No external API keys or services are needed for the checkout operation.

Troubleshooting

  • Common issues:

    • Invalid or non-existent branch/commit specified in Target will cause Git to fail.
    • Incorrect Repository Path that does not point to a Git repository will result in errors.
    • Buffer overflow errors if the command produces too much output; can be mitigated by enabling Skip Stdout.
  • Error messages:

    • Unsupported operation checkout: Indicates the operation parameter was not recognized (unlikely here since it's hardcoded).
    • Git errors like error: pathspec 'branch-name' did not match any file(s) known to git mean the target branch or commit does not exist.
    • File system errors if the repoPath is invalid or inaccessible.
  • Resolutions:

    • Verify the branch or commit exists locally.
    • Ensure the repository path is correct and points to a valid Git repo.
    • Enable Skip Stdout if encountering maxBuffer errors.
    • Check permissions for the filesystem path.

Links and References

Discussion