Skip to content

Git tools of the Flows MCP server ​

The 16 tools that work on the git repository of the active Node-RED project of the controller. That repository holds the flows file, and it is the only way to undo a change made with the other tools. How to connect, and how results and errors come back, is in Flows MCP server.

There are two sets of tools:

  • Project tools: git-commit, git-checkout, git-log, git-branches and git-flow-diff. They exist only while a project is active in Node-RED: when the active project changes, they are replaced and the client is notified. git-commit, git-checkout, git-log and git-branches use the Git Control plugin when Node-RED has it, and Node-RED's own Projects API otherwise, with fewer features; git-flow-diff always reads through the Projects API. git-project-status is always there.
  • Working-copy tools: git-status, git-stage, git-unstage, git-fetch, git-pull, git-push, git-merge, git-reset, git-discard and git-validate-checkout. They need the Git Control plugin and an active project; without them they answer that they are not available.

Git changes files on disk, while Node-RED keeps running the flows it has in memory. The tools that change the files therefore reload the flows from disk afterwards, so that the runtime runs the new version: every node of every tab restarts, and the answer includes the deploy check. git-checkout with Git Control reloads after every switch, git-merge unless the branch was already up to date, git-pull when the plugin reports that the flows changed, and git-discard when the flows file or its credentials file is among the files. (A branch switch made through the Projects API is reloaded by Node-RED itself.) If that reload fails, the runtime still runs the previous flows: call reload-flows, and deploy nothing before it, because a deploy would write the old flows back.

The remote state these tools report (ahead, behind, diverged) is as of the last git-fetch.

Status and history ​

git-project-status ​

Whether Node-RED Projects is available and which project is active, followed by the addresses at which people reach the editor and the dashboards. Takes no parameters. Read-only.

With an active project it adds the number of commits, the current branch, the number of files of the project and whether the Git Control plugin is available. Without one it says why (Projects disabled in settings.js, no active project, an error of the Projects API) and what to do.

git-status ​

Needs Git Control. The state of the working copy: branch, its upstream, commits ahead and behind, whether a remote is configured, and the staged, unstaged, untracked and conflicted files. Takes no parameters. Read-only. Use it before every commit and before switching branch.

git-log ​

The commit history of the project. Read-only.

ParameterTypeRequiredMeaning
limitnumbernoMaximum number of commits. Default 20
fromstringnoFirst commit of a range. Git Control only
tostringnoLast commit of a range. Git Control only

Each commit shows its short hash, subject, author and date. With Git Control it also shows its branches, its parents, and whether it was pushed or exists only on the controller.

git-branches ​

The branches of the project. Takes no parameters. Read-only.

With Git Control: the remotes configured, each local branch with its upstream and how many commits it is ahead and behind, the branches without upstream or whose upstream was deleted on the remote, and the branches that exist only on the remote. Without it: the branches with their last commit.

git-flow-diff ​

A semantic diff of the project's flows between two versions: the tabs and nodes added, removed and changed per tab, the properties that changed (old → new), the changed lines of code and text properties (the code of function nodes, templates, info) as diff hunks, and the nodes that only moved. Credentials are never shown. Read-only.

ParameterTypeRequiredMeaning
basestringnoCommit, branch or tag to compare from. Default HEAD, the last commit
headstringnoWhat to compare to: working (default), the flows file as deployed, with the uncommitted changes; or a commit, branch or tag
tabIdstringnoOnly this tab or subflow
detailsummary or fullnosummary: one line per node; full (default): also the changed lines
limitinteger, 1 to 500noMaximum changed nodes listed. Default 50
offsetinteger, from 0noSkip this many changed nodes

With the defaults it shows what a commit would contain. Use it before committing, and to see exactly what changed when there are uncommitted changes that are not yours.

git-validate-checkout ​

Needs Git Control. Checks whether switching to a branch or commit is safe, without switching. Read-only.

ParameterTypeRequiredMeaning
targetRefstringyesBranch or commit

When the switch is not safe, it lists the blockers, such as uncommitted changes, and says whether HEAD is detached.

Committing ​

git-stage ​

Needs Git Control. Adds files to the next commit. Changes only the git index: the files and the runtime are not touched.

ParameterTypeRequiredMeaning
stageAllbooleannoStage every change. Default false
filesarray of stringsnoThe files to stage

One of the two is required.

git-unstage ​

Needs Git Control. Takes files out of the next commit, keeping their changes. Changes only the git index.

ParameterTypeRequiredMeaning
unstageAllbooleannoUnstage every file. Default false
filesarray of stringsnoThe files to unstage

One of the two is required.

git-commit ​

Creates a commit in the project's repository on the controller. Nothing is pushed.

ParameterTypeRequiredMeaning
messagestringnoCommit message. Default MCP checkpoint
stageAllbooleannoStage every change first. Default true
filesarray of stringsnoStage and commit only these files. Git Control only

Without Git Control every change is staged and committed. With Git Control, a commit made on a detached HEAD gets a new branch so that it is not lost; the answer says so. Returns the short hash and the message.

Branches ​

git-checkout ​

Switches to another branch, or creates one. Node-RED then runs the flows of that branch.

ParameterTypeRequiredMeaning
branchstringyesBranch to switch to
createbooleannoCreate the branch. Default false
validatebooleannoWith Git Control, check first that the switch is safe, as git-validate-checkout does. Default true
forcebooleannoSkip that check. Default false

With Git Control, a switch that the check finds unsafe (because of uncommitted changes, for example) is refused with the reason; after switching, the flows are reloaded from disk. Branches are created through the Projects API. Without Git Control, the switch goes through the Projects API.

git-merge ​

Needs Git Control. Merges a ref into the current branch.

ParameterTypeRequiredMeaning
refstringyesBranch or commit to merge
noFastForwardbooleannoAlways create a merge commit, even when a fast-forward is possible. Default false

Conflicts are reported with the conflicted files, and nothing is reloaded: resolve them and commit. Otherwise the flows are reloaded from disk, unless the branch was already up to date.

Remote ​

git-fetch ​

Needs Git Control. Fetches from the remote without merging, then reports where the current branch, and every other branch with an upstream, stands against it: ahead, behind, diverged, upstream deleted. Takes no parameters. The branch, the files and the runtime are not touched. Answers an error when the project has no remote.

git-pull ​

Needs Git Control. Pulls the upstream of the current branch. Takes no parameters.

  • Nothing to pull: the answer says it is up to date.
  • The local branch and its upstream have diverged: nothing changes, and the answer gives the number of commits on each side and says to merge with git-merge.
  • The merge has conflicts: the conflicted files are listed, and the flows are not reloaded.
  • Otherwise the answer says whether it was a fast-forward or a merge, and the flows are reloaded from disk unless the plugin reports that they did not change.

git-push ​

Needs Git Control. Publishes the local commits to the remote repository, where everyone with access to it sees them. A new branch gets its upstream set. Takes no parameters.

Undoing ​

git-reset ​

Needs Git Control. Moves the current branch to another commit, keeping the files: the running flows do not change.

ParameterTypeRequiredMeaning
commitRefstringyesCommit, branch or a reference such as HEAD~1
resetModesoft, mixed or hardnosoft keeps the changes staged, mixed (default) keeps them unstaged. hard is refused

To throw changes away, use git-discard.

git-discard ​

Needs Git Control. Throws away the uncommitted changes of some files: they get their committed version back. It cannot be undone. When the flows file is among them, the flows are reloaded from disk.

ParameterTypeRequiredMeaning
filesarray of stringsyesThe files, at least one