Git 是目前最流行的版本控制系统之一。本文将介绍 Git 的基本使用方法。
初始化仓库
git init |
基本操作
添加文件
git add . |
提交更改
git commit -m "提交信息" |
查看状态
git status |
查看提交历史
git log |
分支管理
创建分支
git branch branch-name |
切换分支
git checkout branch-name |
合并分支
git merge branch-name |
远程操作
添加远程仓库
git remote add origin https://github.com/user/repo.git |
推送代码
git push -u origin master |
拉取代码
git pull origin master |
总结
Git 是一个强大的版本控制工具,掌握基本操作可以让我们的开发工作更加高效。