以下是一些 Git 常用的命令,帮助你更好地管理你的版本控制。
初始化仓库
git init
添加文件
git add <file>
提交更改
git commit -m "<message>"
查看日志
git log
回滚到上一个版本
git reset --hard HEAD~1
分支管理
# 创建分支
git branch <name>
# 切换到分支
git checkout <name>
# 合并分支
git merge <name>
# 删除分支
git branch -d <name>
其他常用命令
git push
:推送本地分支到远程仓库。git pull
:从远程仓库拉取最新代码到本地。git clone <url>
:克隆远程仓库到本地。
扩展阅读
想了解更多关于 Git 的知识?可以阅读我们的Git 教程。
Git 图标