Git Extended icon

Git Extended

Run Git commands

Overview

The node "Git Extended" allows users to run various Git commands directly within an n8n workflow. The "Switch Branch" operation specifically enables switching the current working branch or commit in a local Git repository. This is useful when automating workflows that require changing branches before performing further Git operations like merging, pulling, or pushing.

Practical examples include:

  • Automatically switching to a feature branch before running tests or deployments.
  • Switching to a specific commit or tag for rollback or inspection purposes.
  • Integrating branch switching as part of a CI/CD pipeline automation.

Properties

Name Meaning
Repository Path Filesystem path where the Git command will be executed. For clone, this is the parent path.
Target Branch name or commit hash to switch to.

Output

The output JSON contains two fields:

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

No binary data is produced by this node.

Example output JSON:

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

Dependencies

  • Requires Git to be installed and accessible on the system where n8n runs.
  • No external API keys or services are needed.
  • The node executes shell commands using the system's Git CLI.

Troubleshooting

  • Common issues:

    • Invalid repository path: Ensure the Repository Path points to a valid Git repository.
    • Non-existent branch or commit: The Target must exist locally or be reachable.
    • Permission errors: The user running n8n must have filesystem permissions to access the repository.
  • Error messages:

    • "fatal: not a git repository" indicates the specified path is not a Git repo.
    • "error: pathspec '<target>' did not match any file(s) known to git" means the target branch or commit does not exist.

To resolve these, verify paths and branch names, and ensure the repository is properly initialized.

Links and References

Discussion