2022-10-24 09:45:19
常用Git命令清单:
基础命令: 初始化代码库:git init 下载项目及历史记录:git clone [url] 新建或切换分支: 新建分支:git branch [branchname] 切换分支:git checkout [branchname] 提交代码:git commit m [message]
高级命令: 增删文件: 添加文件至暂存区:git add [file] 删除文件:git rm [file] 配置: 编辑用户信息:git config user.name "[name]" 显示当前配置:git config list 分支操作: 新建分支并切换:git branch b [branch] 合并分支:git merge [branch] 标签: 新建标签:git tag [tag] 删除标签:git push origin :refs/tags/[tagName] 查看信息: 查看文件状态:git status 显示提交历史:git log 远程仓库操作: 下载远程仓库:git fetch [remote] 同步远程仓库:git pull [remote] [branch] 推送本地代码至远程仓库:git push [remote] [branch] 撤销操作: 恢复文件至工作区:git checkout [file] 撤销并恢复至上一版本:git reset [commit]
掌握这些命令后,您可以在Git中进行高效的操作。不过,要成为Git高手,还需深入理解其工作原理,并灵活应用各种高级功能。