Target remote: https://github.com/SWATGenX/SWATGenX_API
If your local repo is /data/SWATGenXApp/codes (or VahidMSU/SWATGenX) and you run:
git remote add public git@github.com-swatgenx:SWATGenX/SWATGenX_API.git
git push public mainGit sends every commit on main — thousands of objects, scripts/google-services/*.json, etc. GitHub push protection will reject that (secrets in history, large files). The public repo must contain only this folder’s files with a fresh history (see below).
Use a new directory (not inside the monorepo’s .git):
PUB=~/SWATGenX-api-public-only
rm -rf "$PUB"
mkdir -p "$PUB" && cd "$PUB"
git init -b main
rsync -a /data/SWATGenXApp/codes/documents/public_swatgenx_api_examples/ ./
git add -A
git status # should show only README, examples/, docs/, etc. — no scripts/google-services
git -c user.email="you@example.com" -c user.name="Your Name" commit -m "Initial commit: SWATGenX Model Creation API examples"
git remote add origin git@github.com-swatgenx:SWATGenX/SWATGenX_API.git
git push -u origin mainIf GitHub already has a bad partial branch from an earlier attempt, you may need git push -u origin main --force once (only for this small repo, never force the private monorepo blindly).
- GitHub → Settings → Developer settings → Fine-grained tokens → Generate.
- Resource owner: the
SWATGenXorganization (or your user, if the token is user-scoped and you have repo access). - Repository access: select only
SWATGenX/SWATGenX_API(or “All repositories” if you accept broader scope). - Permissions:
- Repository permissions → Contents: Read and write (required for
git pushof files onmain).
This is not the same as Actions read/write (that only affects workflow YAML / Action runs). - Metadata: read-only (default) is enough.
- Repository permissions → Contents: Read and write (required for
- Save the token and store it only on your machine (e.g.
ssl_certificate/public_github_fined_grained_token.jsonwith keyGITHUB_FINE_GRAINED_TOKEN— never commit that file to the public repo).
If git push returns 403 Permission denied, the token is missing Contents: Write or the repo is not included in the token’s repository list.
Keep a single working tree: your public clone (e.g. /data/SWATGenXApp/SWATGenX-api-public-only) and make the monorepo path a symlink into it:
bash /data/SWATGenXApp/codes/scripts/link_public_swatgenx_api_bundle.shThen documents/public_swatgenx_api_examples/ in the private repo resolves to the same files as this directory; edit once, git add / git commit / git push from the public clone for GitHub, or use the publish script below (which still works because it follows the symlink).
On a new machine, recreate the clone and run the link script again (or ln -sfn manually). Relative symlinks assume the usual layout: SWATGenXApp/codes next to SWATGenXApp/SWATGenX-api-public-only.
From the private checkout (uses GIT_ASKPASS so the token is not stored in git remote):
bash /data/SWATGenXApp/codes/scripts/publish_public_swatgenx_api.shOverride token path if needed: SWATGENX_PUBLIC_GITHUB_TOKEN_JSON=/path/to.json.
If Git prompts for HTTPS credentials via GIT_ASKPASS, set SWATGENX_GITHUB_USERNAME to the GitHub account name that owns the fine-grained token (defaults to Vahidr32 in the script).
The script clones SWATGenX/SWATGenX_API, copies documents/public_swatgenx_api_examples/ over the tree (symlink source is resolved), commits if there are changes, and pushes using GIT_ASKPASS (token is not embedded in the remote URL).
If the GitHub repo is empty, the script creates the first commit on main and pushes. Ensure the default branch on GitHub is main (GitHub’s default for new repos).