These are stored in your ~/.gitconfig. They automate the heavy lifting of syncing and cleaning.
This detects your current branch and updates it from the official Cacti repository.
git config --global alias.sync '!f() { \
local branch=$(git rev-parse --abbrev-ref HEAD); \
git fetch upstream && \
git merge upstream/$branch && \
git push origin $branch; \
}; f'
This identifies branches that have been merged and deleted on GitHub and removes them from your local machine.
git config --global alias.gone '!f() { \
git fetch -p && \
git branch -vv | awk "/: gone] / {print \$1}" | xargs -r git branch -d; \
}; f'
These scripts assist with bulk management across your /plugins directory.
Run this from your plugins/ directory to update every single plugin at once.
sync_all.sh
!#/bin/bash
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c 'echo "Syncing {}..."; cd "{}" && git sync';
Follow these steps every time you want to submit a change (like a typo fix).
- Navigate to the plugin or core directory.
- Ensure you are on the main branch (e.g., git checkout develop or git checkout main).
- Run git sync to ensure your local and fork are identical to the official Cacti code.
Never work directly on develop or main.
git checkout -b fix-typo-auth-logs
- Run
typos -w <filename>to fix errors. - Review the changes with git diff.
- Run the Cacti-specific tests or linting if applicable.
- Stage:
git add <filename> - Commit:
git commit -m "Brief description of fix" - Push:
git push origin fix-typo-auth-logs
- Go to the official Cacti repository on GitHub.
- Click "Compare & pull request" on the yellow bar that appears.
- Verify the "base" is the official repo and the "head" is your fork's branch.
- Submit the PR.
- Once merged, click "Delete branch" in the GitHub GUI.
- Back in your terminal:
git checkout develop(or main). - Run
git sync(to get your own fix into your main branch). - Run
git gone(to delete the local feature branch).- *Note: If git gone fails because the IDs differ, use
git branch -D <branch-name>.*
- *Note: If git gone fails because the IDs differ, use
- "Upstream not found": Run git remote add upstream git@github.com:Cacti/<repo_name>.git.
- "X11 forwarding failed": This is a harmless SSH warning; you can ignore it or use ssh -x to suppress it.
- "Permission Denied (publickey)": Run ssh-add ~/.ssh/id_ecdsa to ensure your key is loaded into the agent.
This script will use the GitHub CLI (gh) to automate the tedious process of finding, forking, and cloning every official Cacti plugin.
The mass-fork.sh Script
Create this file in your /plugins directory.
#!/bin/bash
# 1. Define the organization we are targeting
ORG="Cacti"
echo "Fetching list of all Cacti repositories..."
# 2. Get all repo names from the Cacti org that start with 'plugin_'
# We use --limit 300 to ensure we catch everything
REPOS=$(gh repo list $ORG --limit 300 --json name --jq '.[].name' | grep '^plugin_')
echo "Found $(echo "$REPOS" | wc -l) plugins."
# 3. Loop through and fork/clone
for REPO in $REPOS; do
if [ -d "$REPO" ]; then
echo "$REPO already exists locally, skipping..."
else
echo "Forking and cloning $REPO..."
# --clone=true forks it to your account and downloads it
# --remote=true sets up 'upstream' (Cacti) and 'origin' (You) automatically
gh repo fork "$ORG/$REPO" --clone --remote
fi
done
echo "All plugins are synced and ready"
How to use it
Make it executable:
chmod +x mass-fork.sh
Run it:
./mass-fork.sh
Automatic Remotes: Because of the --remote flag, you don't have to manually run git remote add upstream. Your git sync alias will work immediately on every single plugin this script downloads.
Duplicate Protection: It checks if the folder already exists (if [ -d "$REPO" ]) so you can run this script once a month to grab any new plugins the Cacti team has released without re-downloading everything.
Filtered: It specifically looks for the plugin_ prefix so you don't accidentally fork the main Cacti docs, website, or spine repositories into your plugins folder.
Since you are managing a massive library now, you might want a way to see which plugins have uncommitted changes across your entire workspace. Run this to add a "status all" command:
git config --global alias.status-all '!f() { find . -maxdepth 2 -name ".git" -exec sh -c "echo \"\nChecking {}...\" && cd {}/.. && git status -s" \;; }; f'
(Now, typing git status-all from your plugins/ folder will give you a bird's-eye view of every plugin you're currently working on.)
gh cache delete --all
gh workflow list --json id -q '.[].id' | xargs -I {} gh workflow disable {}
For example - "Nightly PHP Heavy Checks"
- Go to your fork's Actions tab on GitHub.
- In the left sidebar, click "Nightly PHP Heavy Checks".
- Click the "..." (ellipsis) menu in the top-right of the workflow page.
- Select "Disable workflow".
Loop for plugins directory:
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c 'cd "{}" && echo "Checking {}..." && gh workflow list --json id -q ".[].id" | xargs -I {} gh workflow disable {}' \;