📂 git init = Start Version Control
New project? git init creates .git folder. Start tracking changes. Essential for any project.
📝 Git Init
# Initialize repository git init # Initialize in specific directory git init my-project # Initialize with default branch name git init --initial-branch=main # Initialize bare repository (for server) git init --bare # After init: # - .git folder created # - Repository is ready # First steps after init: git add . git commit -m "Initial commit" # Add remote (optional) git remote add origin https://github.com/user/repo.git git push -u origin main
🎯 Common Workflow
1. Create project folder mkdir my-project cd my-project 2. Initialize Git git init 3. Create .gitignore echo "node_modules/" > .gitignore echo ".env" >> .gitignore 4. Add files git add . git commit -m "Initial commit" 5. Add remote (GitHub) git remote add origin https://github.com/user/repo.git git push -u origin main
💡 Tips
- Always init before adding files
- Create .gitignore before first commit
- Use main as default branch
- Initial commit sets base state
“git init starts version control. Essential for any project. Track changes from day one.”
