登录 Git 初始化
用户信息
全局信息
设置个人信息
shell
git config --global user.name 'zhengxinonly'
git config --global user.email 'pyxxponly@gmail.com'查看个人信息
shell
git config --global user.name
git config --global user.email
# 查看所有的配置
git config --global --listgit 配置存放位置,的全局配置一般会存在 home 目录的 .gitconfig 文件。如 /home/ubuntu/.gitconfig。
可以通过以下命令查看全局配置的内容:
shell
cat ~/.gitconfig局部信息
设置信息
shell
# 进入项目的根目录
cd [project_dir]
# 设置用户名和邮箱
git config user.name 'zhengxinonly'
git config user.email 'pyxxponly@gmail.com'查看信息
shell
git config user.name
git config user.email针对指定项目的配置会存在项目目录的 .git/config 文件。如 ./<project_dir>/.git/config。
这个配置只针对你当前的项目有效,且优先级高于全局配置(如全局配置的 user.name 是 zhengxinonly,项目配置的 user.name 是 zhengxin,那么实际上你在这个项目中提交的 commit 的用户名是 zhengxin)。