git-workflow-guide
π git-workflow-guide.md
β Junior Git Workflow & Push Guideβ
# π Junior Git Workflow & Branching Guide
This document provides best practices and tips for working with Git in the Junior organization β especially across teams like Java Backend, LLM Core, DevOps, and Frontend.
---
## π± Branch Naming Convention
| Type | Prefix | Example |
|------|--------|---------|
| Feature | `feat/` | `feat/auth-oauth2` |
| Fix | `fix/` | `fix/login-null-crash` |
| Docs | `docs/` | `docs/update-readme` |
| Refactor | `refactor/` | `refactor/token-refresh-flow` |
| Test | `test/` | `test/unit-auth` |
| Chore | `chore/` | `chore/remove-logs` |
---
## π Local Branch Creation
```bash
# Create and switch to new branch
git checkout -b feat/add-oauth-support
π€ First Time Push of a New Branchβ
# Push your local branch and set it to track the same remote branch
git push --set-upstream origin feat/add-oauth-support
After that, you can just use:
git push # To push changes
git pull # To pull latest changes
β οΈ Common Push Errors & Fixesβ
1. fatal: no upstream branch
β
You tried pushing a branch thatβs not tracking a remote. Use:
git push --set-upstream origin your-branch-name
2. fatal: current branch does not match remote
β
Git is unsure whether to push to main
or same-named branch. Choose:
# Push to same branch name on remote
git push origin HEAD
# OR push to a specific branch like main (be careful!)
git push origin HEAD:main
π Avoid Accidental Push to main
β
β Only maintainers/admins should push directly to
main
.
Use GitHubβs branch protection rules:
- Require pull requests
- Require code reviews
- Allow only selected people to merge
- Disallow direct push to
main
π§Ή Cleaning Upβ
Delete a local branch after merging:β
git branch -d branch-name
Delete a remote branch:β
git push origin --delete branch-name
π§ͺ Git Checkpointsβ
git status # What has changed?
git log # What commits were made?
git branch -vv # What are you tracking?
git remote -v # Check remote URL
π Set Remote URLβ
# If remote not set
git remote add origin https://github.com/All-Origin/YourRepoName.git
β Commit Messages Formatβ
type(scope): short description
# Example:
feat(auth): add Google OAuth login support
fix(otp): handle resend timeout bug
docs(readme): update setup section
π§ Summaryβ
Command | Description |
---|---|
git push --set-upstream origin <branch> | Push + track remote |
git push origin HEAD | Push to same name on remote |
git push origin HEAD:main | Push current branch into main (not recommended) |
git branch --set-upstream-to=origin/<branch> | Set upstream for existing branch |
git remote -v | See remotes |
git status | See current repo state |
β¨ work responsibly, push mindfully, and code confidently.β
β Junior Ai Engineering Team