git基本配置
//查看用户名
git config user.name
//查看用户邮箱地址
git config user.email
修改用户地址和邮箱
修改用户名称
git config --global user.name "username"
修改邮箱地址
git config --global user.email "email@xxx.com"
最小配置
1. 配置user信息(必须,不配置的话,最后Git做变更提交时会出现提示信息,提示需要做相关配置)
git config [--local | --global | --system] user.name 'your_name'
git config [--local | --global | --system] user.email 'your_email@domain.com'
作用域区别:
local:只对用户当前工作仓库有效(缺省值)
global:对当前用户所有仓库有效(常用)
system:对系统所有登录的用户有效(不常用)
注:优先级为local > global > system
2. 显示config的配置
git config --list [--local | --global | --system]
3. 清除unset
git config --unset [--local | --global | --system] user.name
git 重命名文件
git mv readme readme.me
[@xpMac:odm (master)]$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: readme -> readme.me
git 提交文件
git commit -m'rename'
git 清空暂存区
git reset --hard
注意:该操作很危险,之前修改的被纳入暂存区的内容都会消失