git命令大全
Git是一个开源的分布式版本控制系统,可以有效、高效地处理从小型到大型项目的版本管理。以下是Git的一些常见命令:
配置Git的配置文件分为系统级、全局和项目级。
系统级配置:
git config --system user.name "your_name"
git config --system user.email "your_email@example.com"
全局配置:
git config --global user.name "your_name"
git config --global user.email "your_email@example.com"
项目级配置:
git config user.name "your_name"
git config user.email "your_email@example.com"
初始化一个新的Git仓库:
git init
克隆一个远程仓库到本地:
git clone https://github.com/user/repo.git
查看当前仓库的状态:
git status
添加文件到暂存区:
git add
git add .
提交暂存区的变化到仓库:
git commit -m "提交说明"
查看提交历史:
git log
比较文件的不同:
git diff
创建分支:
git branch <branch_name>
切换分支:
git checkout <branch_name>
创建并切换到新分支:
git checkout -b <branch_name>
合并分支:
git merge <branch_name>
删除分支:
git branch -d <branch_name>
推送到远程仓库:
git push origin <branch_name>
拉取远程仓库的变化:
git pull origin <branch_name>
标签管理:
创建一个标签:
git tag <tag_name>
推送一个标签到远程:
git push origin <tag_name>
撤销更改:
撤销工作区的修改:
git checkout --
撤销暂存区的修改:
git reset HEAD
撤销已经提交的修改:
git revert
删除文件:
git rm
查看远程仓库:
git remote -v
添加远程仓库:
git remote add origin <remote_url>
以上是Git的一些基本操作命令,具体使用时需要根据实际需求选择合适的命令。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· Vue3状态管理终极指南:Pinia保姆级教程