Development Workflow

Git Basics Every PHP Developer Should Know

Learn the essential Git commands for tracking PHP project changes, reviewing work, and maintaining a useful commit history.

Initialize a repository

Inside your project directory:

git init
git status

Create a .gitignore file so generated files and secrets are not accidentally committed:

/vendor/
/.env
/storage/logs/
/cache/

Adapt these paths to your application's structure. Never commit passwords, API keys, private configuration files, or user uploads.

Track and commit changes

git add app/
git add composer.json composer.lock
git status
git commit -m "Add article management"

Review git status before committing. It shows staged, unstaged, and untracked files.

Inspect project history

git log --oneline
git diff
git diff --staged

These commands help you understand what changed and what will be included in the next commit.

Work with a remote repository

git remote add origin https://example.com/your/project.git
git push -u origin main

Use the actual remote URL supplied by your Git hosting provider.

Good habits

Make focused commits with clear messages, keep secrets out of the repository, and test changes before pushing. Git is a change-history tool; it does not replace backups or a deployment process.