Welcome to the Git tutorial! This guide will walk you through the essentials of using Git for version control. Whether you're a beginner or looking to refine your skills, you'll find practical examples and clear explanations here. Let's get started!
What is Git? 🤔
Git is a distributed version control system designed to handle everything from small projects to large-scale collaborations. It tracks changes in your code, allowing you to revert to previous versions, review history, and manage multiple contributors seamlessly.
⚠️ Tip: For a deeper dive into Git's architecture, visit our /zh/docs/developer/git_architecture guide.
Getting Started 🚀
Install Git
Download from git-scm.com and follow the installation wizard.Configure Your Name and Email
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
Initialize a Repository
git init
Core Concepts 🔍
- Repository ( Repo ) - A directory containing all project files and history.
- Commit - A snapshot of your project at a specific point in time.
- Branch - An independent line of development. Use
git branch feature-x
to create one. - Merge - Combine changes from different branches. Avoid conflicts by using
git merge --no-ff
for better history.
Branching and Merging 📌
graph TD
A[Main Branch] --> B[Feature Branch]
B --> C{Merge?}
C -->|Yes| D[Main Branch]
C -->|No| E[Continue Development]
Visualizing branch workflows. Learn more about branching strategies.
Collaborative Workflow 🤝
- Fork the project on GitHub
- Clone your fork:
git clone https://github.com/yourname/project.git
- Create a new branch:
git checkout -b bugfix-123
- Commit changes:
git commit -m "Fix login bug"
- Push to your fork:
git push origin bugfix-123
- Open a pull request to merge into the main repo