2.7 KiB
2.7 KiB
Git Workflow and Branch Protection
Goal
masteris currently unprotected; contributors can push directly. Prefer feature branches + PRs so changes stay reviewable and CI-visible.
Remotes
- Forgejo repo:
ssh://git@git.halla-aho.net:2223/thalla/lomavuokraus.git - Add remote if missing:
git remote add origin ssh://git@git.halla-aho.net:2223/thalla/lomavuokraus.git - Verify:
git remote -v
Daily flow
- Sync
master:git checkout master git pull --rebase # or `git pull` if you prefer merges; see config below - Create a feature branch:
git checkout -b feature/<short-name> - Commit locally:
git status git add <files> git commit -m "Your change" - Push branch to Forgejo:
git push -u origin feature/<short-name> - Open a PR targeting
masterin Forgejo. - Get review + approvals; ensure CI passes.
- Merge via the PR; direct pushes work but are discouraged.
- After merge, sync local master:
git checkout master git pull --rebase git branch -d feature/<short-name> # cleanup
Branch protection (set in Forgejo UI)
- Currently disabled on
master. To re-enable:- Settings → Branches → Protect
master. - Prevent direct pushes (except admins if desired).
- Require pull requests and at least 1 approval.
- Restrict who can push (admins/maintainers).
- Optionally dismiss stale approvals and require status checks (CI).
- Settings → Branches → Protect
Recommended local config
- Default pull strategy (pick one):
- Rebase pulls:
git config pull.rebase true - Merge pulls:
git config pull.rebase false - Fast-forward only:
git config pull.ff only
- Rebase pulls:
- Set your user:
git config user.name "Your Name" git config user.email "you@example.com"
Common troubleshooting
- Divergent branches on pull: set pull strategy (see above) and rerun
git pull --rebaseorgit pull. - “Remote not found”: add
originremote (see Remotes). - Push rejected (if protection is re-enabled): push to a feature branch and open a PR.
- Conflicts during pull/rebase:
git status # see conflicted files # edit files to resolve git add <files> git rebase --continue # if rebasing git commit # if merging - Wrong branch for work: create a new branch and move commits:
git checkout -b feature/fix git push -u origin feature/fix - Clean up merged branches locally:
git branch --merged masterthengit branch -d <branch>.
CI
- Workflows live under
.forgejo/workflows/. Ensure CI passes before merging.
Secrets and kubeconfig
creds/is git-ignored; place kubeconfig atcreds/kubeconfig.yamlor setKUBECONFIG.- Age/SOPS key: store at
~/.config/age/keys.txtor setSOPS_AGE_KEY_FILE.