什么是 Git
Git 是一个分布式版本控制系统,由 Linus Torvalds 创建,用于管理源代码的版本历史。
常用命令
# 初始化仓库
git init
# 克隆远程仓库
git clone <url>
# 查看状态
git status
# 提交更改
git add .
git commit -m "描述信息"
分支管理
分支是 Git 最强大的特性之一,允许你并行开发而不影响主线代码。
# 创建并切换到新分支
git checkout -b feature/new-feature
# 合并分支
git merge feature/new-feature
# 删除分支
git branch -d feature/new-feature
远程协作
# 添加远程仓库
git remote add origin <url>
# 推送代码
git push origin main
# 拉取最新代码
git pull origin main