Git Integration
Version-control the Workspace from inside NetStacks: status, diff, blame, history, stage and commit, branch, merge, rebase, stash, and push/pull to remotes.
Overview
When a Workspace folder is a Git repository, NetStacks detects it and exposes a full Git workflow directly in the UI. This keeps your scripts, templates, and config artifacts versioned alongside the device work that motivated them, instead of round-tripping through a separate Git client or shell.
Every operation runs locally: the NetStacks Agent shells out to thegit binary against the Workspace repository on your own machine. The only network traffic is between your machine and the Git remote you configured. Your repository contents are never sent to NetStacks.
Git tracks whatever is in the Workspace folder — Jinja2 templates, Python/Ansible automation, parsed device state, MOP artifacts, and notes. Pair it with the code editor so the edit, review, and commit loop all happen in one place.
The Git Panel
The Git panel sits beside the file explorer and is organized into three tabs, with a toolbar for the remote operations:
- Changes
- Working-tree status, the staging area, the diff viewer, and the commit box. This is your day-to-day tab.
- History
- The commit log for the current branch, with per-commit details and file-level blame.
- Branches
- List, create, switch, delete, and merge branches, plus the stash list.
The panel toolbar carries Fetch, Pull, Push, and a Clean Up History action for interactive rebase.
Changes: Stage, Diff & Commit
The Changes tab shows modified, added, deleted, renamed, and untracked files, split into staged and unstaged groups — the same information git status gives you. Stage files individually or all at once, then review the diff before committing.
Selecting a file opens the diff viewer so you can inspect exactly what changed, the same content git diff produces:
# The equivalents of the Changes-tab actions
git status # working-tree state (staged vs. unstaged)
git add path/to/file # stage a single file
git add -A # stage everything
git diff # unstaged changes
git diff --staged # what a commit would record
git restore path # discard / revert a file (the "Revert" action)Committing
Write a commit message in the box and commit. Two commit actions are available: Commit and Commit & Push. NetStacks uses a smart-commit convenience: if nothing is staged but you have unstaged changes, it stages them all for you before committing (matching the common editor default).
With an empty message box, press Tab to draft a commit message from your pending diff. NetStacks sends the staged diff (or the working-tree diff if nothing is staged yet) to the AI and asks for a concise, conventional-commit-style message, giving you a starting point to edit rather than staring at an empty box. Always review and refine it before committing.
You can also amend the last commit when you need to fix its message or fold in a forgotten change:
# Standard commit
git commit -m "Add BGP peer template for spine-leaf fabric"
# Amend the most recent commit (the "amend" action)
git commit --amend -m "Add BGP peer template for spine-leaf fabric (v2)"History & Blame
The History tab lists commits on the current branch with hash, subject, author, and date. Open a file's blame to see which commit last touched each line — useful for tracing when a template variable or a generated config value changed.
# History tab
git log --oneline -20
# Per-file blame (the Blame view)
git blame templates/bgp.j2Branches, Merge & Stash
The Branches tab lists local branches and lets you create, switch, delete, and merge. Branch per change: a short-lived branch makes an experimental config script easy to throw away or merge cleanly.
# Create a branch for a change and switch to it
git switch -c feature/ospf-redistribute
# ... edit, stage, commit ...
# Merge it back (NetStacks merges with --no-ff to preserve the branch point)
git switch main
git merge --no-ff feature/ospf-redistribute
# Delete the branch when done
git branch -d feature/ospf-redistributeStash
Need to switch context with uncommitted work in flight? Stash it from the Branches tab. The stash list shows saved entries; pop or drop them when you come back.
git stash # shelve uncommitted changes
git stash list # see saved stashes
git stash pop # restore the most recent and remove it
git stash drop # discard a stash without restoringClean Up History (Rebase)
The Clean Up History action opens an interactive rebase editor over the most recent commits so you can reorder, reword, or squash before pushing — handy for tidying a messy work-in-progress branch into a few meaningful commits. The rebase can be applied or aborted from the editor.
Interactive rebase changes commit hashes. Only clean up commits that you have not yet shared on a remote, or be prepared to force-push to a branch nobody else has based work on.
# The shell equivalent of the Clean Up History editor
git rebase -i HEAD~5 # reorder / reword / squash the last 5 commits
git rebase --abort # back out if something goes wrongRemotes & Git Accounts
Push and pull against your remote without dropping to a shell. NetStacks stores the credentials it needs to authenticate to common hosts under a Git Accounts settings tab. Each account holds a name, a provider, an optional host (for self-hosted installs), and a Personal Access Token. Tokens are stored locally by the Agent in its database on your own machine — whose file is restricted to your user account — and are never sent to NetStacks.
The supported providers are:
- GitHub — github.com.
- GitHub Enterprise — your self-hosted GHE host.
- GitLab — gitlab.com.
- GitLab Self-Hosted — your own GitLab instance.
- Gitea — gitea.com or your own Gitea host.
- Bitbucket — bitbucket.org.
For GitHub Enterprise, GitLab Self-Hosted, and Gitea you also provide the host URL (for example https://ghe.corp.net). TheTest connection button validates the token against the provider's user endpoint and reports back the authenticated username before you save.
Which operations are available depends on the remote and the credentials you have configured for it. Read-only and local use — status, diff, blame, history, staging, branching, stashing, and local commits — works with no remote at all.
Worked Example
A typical end-to-end flow: branch, edit, draft a commit message, then commit and push. In the UI this is a few clicks across the Changes and Branches tabs; here are the equivalent commands so the steps are unambiguous.
# 1. Configure a Git Account once (Settings -> Git Accounts):
# Name: "Work GitHub" Provider: GitHub Token: ghp_... Default: yes
# (Use the Test connection button to confirm the token works.)
# 2. Branch for the change (Branches tab)
git switch -c feature/add-mgmt-vlan
# 3. Edit templates/configs in the code editor, then stage (Changes tab)
git add -A
# 4. Draft a message (press Tab in the empty box), edit it, then commit + push
git commit -m "Add management VLAN to access-switch template"
git push -u origin feature/add-mgmt-vlan
# 5. Open a PR on the remote, or merge locally:
git switch main && git merge --no-ff feature/add-mgmt-vlan && git pushThe Git Account you marked as default supplies the token used for the push step, so no shell credential prompt appears.
Q&A
- Q: Do I need a remote to use Git here?
- A: No. Status, diff, blame, history, staging, branching, merging, stashing, rebasing, and local commits all work on any local repository. A remote (and a Git Account) is only needed to fetch, pull, or push.
- Q: Which hosts are supported for push/pull?
- A: GitHub, GitHub Enterprise, GitLab, GitLab Self-Hosted, Gitea, and Bitbucket, each with a stored Personal Access Token.
- Q: How is the drafted commit message generated?
- A: Press Tab in the empty commit box and NetStacks sends your pending diff to the AI, asking for a concise conventional-commit-style message. It is a starting point — review and edit it before committing. For broader LLM-assisted authoring of scripts and configs, see the AI features.
- Q: Where are Git credentials stored?
- A: Locally by the Agent in its database on your machine, configured under the Git Accounts settings tab. The database file is restricted to your user account, and tokens are never sent to NetStacks. For more on local secret handling, see the vault.
- Q: Are my repository contents sent to NetStacks?
- A: No. Git runs locally via the Agent; the only network traffic is between your machine and the Git remote you configured.
- Q: Can I rewrite commit history?
- A: Yes — use Clean Up History (interactive rebase) to reorder, reword, or squash recent commits, and amend to fix the last commit. Only rewrite history you have not yet shared.
Related Features
- Code Editor — make the edits you stage and commit.
- File Explorer — browse and manage the files in the repository.
- Workspace Overview — how the Workspace folder fits together.
- Credential Vault — how local secrets are protected on your machine.
- API Tokens — managing Personal Access Tokens and other API credentials.