| name | git-workflow |
| description | Manage day-to-day Git workflow with safe branch creation, conventional commits, rebasing, pushing, MR creation, active-branch sync, and integration-branch consolidation. Use when the user asks to create branches, commit, push, sync feature/fix branches, rebuild dev branches, or open merge requests. |
Git Workflow
Core Rules
- Always sync remotes first:
git fetch --all --prune
- Always detect default branch dynamically (fallback
main, then master):
default_branch="$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')"
[ -z "$default_branch" ] && default_branch="$(git branch -r --list 'origin/main' | head -n1 | sed 's@^ *origin/@@')"
[ -z "$default_branch" ] && default_branch=master
- Ask for confirmation before destructive operations:
git push --force-with-lease
git reset --hard
- deleting branches/tags
- Never use plain
--force; use --force-with-lease.
- Prefer
origin/<default-branch> as rebase target.
Branch and Commit Conventions
- Branch prefixes:
feature/<name>
fix/<name>
hotfix/<name>
release/<name>
chore/<name>
- Commit prefixes:
feat:, fix:, perf:, refactor:, docs:, test:, chore:, release:
Bundled Helpers
Use these scripts from this skill directory:
scripts/detect-active-branches.sh [--base <branch>] [--window <n>]
scripts/generate-mr-url.sh [source-branch] [target-branch]
generate-mr-url.sh supports generic GitLab remotes (not only git.tec-do.com).
Workflow A: Create Branch
- Ensure repo is up to date:
git fetch --all --prune
- Pick base branch:
- default:
origin/<default-branch>
- use user-provided base if specified
- Normalize branch name:
- If no prefix, infer one from intent (
feature, fix, chore, release, hotfix)
- Convert spaces/underscores to
-
- Create and checkout:
git checkout -b <prefix>/<slug> origin/<base-branch>
- If user asks to publish branch, push:
git push -u origin <branch>
- Show MR URL:
bash scripts/generate-mr-url.sh <branch> <default-branch>
Workflow B: Commit, Push, and MR
1. Branch safety decision
- Detect current branch:
current_branch="$(git branch --show-current)"
- If current branch is protected/integration (
main, master, develop, dev, staging) or user requested new branch:
- create a new branch from
origin/<default-branch> and continue there.
- If current branch is feature/fix style, verify it is not stale:
git cherry "origin/$default_branch" HEAD
- If all commits are already upstream (only
- lines), treat as stale and create a fresh branch.
2. Rebase onto latest default branch
- Stash if worktree is dirty:
git stash push -u -m "git-workflow-auto-stash"
- Rebase:
git rebase "origin/$default_branch"
- If conflicts occur, ask user to resolve and continue:
git rebase --continue
- Restore stash if created:
git stash pop
3. Stage and commit
- Review status:
git status --short
- If user did not ask for partial staging, stage all:
git add -A
- Propose conventional commit title based on diff intent.
- Ask for confirmation/edits on commit message.
- Commit:
git commit -m "<type>: <summary>"
4. Push
- If rebase happened, default to:
git push --force-with-lease origin <current-branch>
Ask for confirmation first.
- Otherwise:
git push -u origin <current-branch>
- Always print MR URL:
bash scripts/generate-mr-url.sh <current-branch> <default-branch>
5. Create MR when requested
If user explicitly requested MR creation:
- Prefer
glab mr create when authenticated.
- Build title/body from commits:
git log "origin/$default_branch"..HEAD --pretty=format:'- %s' --reverse
- Create MR:
glab mr create \
--target-branch "$default_branch" \
--source-branch "$(git branch --show-current)" \
--title "<title>" \
--description "<description>"
- If
glab is unavailable, return URL from generate-mr-url.sh.
Workflow C: Sync Active Feature/Fix Branches
- Save current branch:
origin_branch="$(git branch --show-current)"
- Detect candidates:
bash scripts/detect-active-branches.sh --base "$default_branch"
- Show candidate list and ask user which branches to sync.
- For each selected branch:
git checkout <branch>
git rebase "origin/$default_branch"
- Resolve conflicts with user if needed
- confirm then
git push --force-with-lease origin <branch>
- print MR URL via helper script
- Return to original branch.
Workflow D: Consolidate Integration Branch
Use for requests like "rebuild dev from active features".
- Ask for target integration branch (default
dev).
- Detect active branches using helper script.
- Ask user to confirm branch list and base feature branch.
- Rebase each feature branch on
origin/<default-branch> first.
- Checkout target branch and hard reset to base feature branch:
git checkout <target-branch>
git reset --hard <base-feature-branch>
Ask confirmation before reset.
- Merge remaining feature branches one by one:
git merge --no-ff <feature-branch>
- Ask before push, then push and provide MR URL.
Autonomy Principle
Make reasonable defaults automatically (prefix selection, staging, commit type, target branch).
Ask only when:
- action is destructive
- user intent is ambiguous
- required information cannot be inferred