Programming

Git flow — branches, commits and teamwork

Admin Główny 20.10.2026 51 wyświetleń 0 komentarzy
This translation was generated by AI and may contain inaccuracies. Read the original (PL)

Branch naming convention

feature/blog-markdown-preview
fix/login-redirect-loop
chore/update-symfony-7.2
release/2.1.0
hotfix/critical-xss-vulnerability

Rules:

  • lowercase, words separated by -
  • the prefix describes the type of work
  • short but descriptive

Conventional Commits

Format: type(scope): description

git commit -m "feat(blog): add markdown live preview"
git commit -m "fix(auth): redirect loop on logout fixed"
git commit -m "chore(deps): bump symfony/framework-bundle to 7.2"
git commit -m "docs(readme): update installation steps"
git commit -m "refactor(api): extract ArticleSerializer service"
git commit -m "test(blog): add unit tests for MarkdownExtension"

Types: feat, fix, chore, docs, refactor, test, style, perf


Typical workflow

# 1. Fetch updates from main
git fetch origin
git checkout main
git pull origin main

# 2. Create a new branch
git checkout -b feature/blog-search

# 3. Work... commit by commit
git add src/Controller/BlogController.php
git commit -m "feat(blog): add full-text search endpoint"

# 4. Before merge — rebase onto main
git fetch origin
git rebase origin/main

# 5. Push and open a Pull Request
git push origin feature/blog-search

Interactive rebase — tidy up history

Before merging it's worth cleaning up commits:

git rebase -i HEAD~5

Possible actions:

  • pick — keep the commit
  • squash / s — merge with the previous one
  • reword / r — change the commit message
  • drop / d — remove the commit

Resolving conflicts

git fetch origin
git merge origin/main

# Git will point out files with conflicts:
# CONFLICT (content): Merge conflict in src/Controller/BlogController.php

# Edit the file, remove the <<< === >>> markers
# Then:
git add src/Controller/BlogController.php
git commit

.gitignore for Symfony

/vendor/
/var/
/.env.local
/.env.*.local
/public/bundles/
/node_modules/
/.idea/
/.vscode/
*.swp

Useful aliases

git config --global alias.lg "log --oneline --graph --all --decorate"
git config --global alias.st "status -sb"
git config --global alias.co "checkout"
git config --global alias.br "branch -vva"

The effect of git lg:

* a1b2c3d (HEAD → feature/blog) feat(blog): add search
* e4f5g6h (origin/main) fix(auth): token expiry
*   i7j8k9l Merge pull request #42
|\
| * l0m1n2o feat(api): add pagination
* | o3p4q5r chore: update dependencies
|/
Tagi: #Linux #Git #CI/CD
Udostępnij: Facebook X LinkedIn

Komentarze (0)


Bądź pierwszy — zostaw komentarz!

Zaloguj się, aby dodać komentarz.