git 常用命令
命令名称 | 作用 |
git config --global user.name 用户名 | 设置用户签名 |
git config --global user.email 邮箱 | 设置用户签名 |
git init | 初始化本地库 |
git status | 查看本地库状态 |
git add 文件名 | 添加到暂存区 |
git commit -m "日志信息" 文件名 | 提交到本地库 |
git reflog | 查看历史记录 |
git reset --hard 版本号 | 版本穿梭 |
git pull | 拉取远程代码 |
git push | 推送本地代码到远程 |
git stash | 存储临时改动的代码 |
git stash pop | 释放临时改动的代码 |
git rm -r --cached . | 清除本地缓存 |
分支操作
命令名称 | 作用 |
git branch 分支名 | 创建新的分支 |
git branch -v | 查看当前分支 |
git checkout 分支名 | 切换分支 |
git branch -a | 查看所有分支 |
git branch -d 分支名 | 删除分支 |
git merge 分支名 | 把指定的分支合并到当前分支上 |
查看配置信息
命令名称 | 作用 |
git config --list --global | 查看全局配置信息 |
git config user.email | 查看当前项目指定信息 |
git config --global user.name | 查看全局指定信息 |
git config user.name "worker95" git config user.email "worker95@work.com" |
局部配置,针对具体项目,在项目目录下运行命令 |
git config user.name git config user.email |
查看项目的局部配置,在项目目录下运行 |