git--修改用户名和邮箱的方法(全局修改和局部修改)

原文网址:git--修改用户名和邮箱的方法(全局修改和局部修改)_IT利刃出鞘的博客-CSDN博客

简介

        本文介绍如何修改git的用户名和邮箱,包括:如何全局修改用户名和邮箱,如何只修改某个项目的用户名和密码)。

        如果配置了局部的用户名和邮箱,则会优先使用局部的;如果没有配置局部的用户名和邮箱,则会使用全局的。

粉丝福利:有很多粉丝私信问我有没有Java的面试及PDF书籍等资料,我整理一下,包含:真实面试题汇总、简历模板、PDF书籍、PPT模板等。这些是我自己也在用的资料,面试题是面试官问到我的问题的整理,其他资料也是我自用的,真正实用、靠谱。资料可以从这里免费获取:资料地址

修改方法

全局修改

git config --global user.name "Tony"
git config --global user.email "abc@qq.com"

修改完后,会自动在 C:\Users\xxx\.gitconfig文件添加如下内容:

[user]
    name = Tony
    email = abc@qq.com

局部修改

        有时候,我们想在某个项目里用其他的用户名。比如:在公司里时,有时会修改个人的代码然后提交,想用单独的用户名,不跟公司的项目一样。

git config user.name "Tony"
git config user.email "abc@qq.com"

修改完后,会自动在 (当前目录).git/config文件添加如下内容:

[user]
    name = Tony
    email = abc@qq.com

批量修改

如果挨个去改会很麻烦,可以批量去改某个文件夹下的所有项目。比如,我想修改tmp文件夹下的所有项目的用户名,方法如下:

1.新建shell脚本

在tmp下新建脚本,命名为:git_config.sh,内容如下:

#!/bin/bash
topDir=`pwd`
echo "开始处理"
for file in `ls ./`
do
    fullPath="$topDir/$file/"
    if [ -d "$fullPath" ]; then
        cd "$fullPath";
        if [ -d "$fullPath/.git/" ]; then
            git config user.name "water";
            git config user.email "2716552863@qq.com";
            echo "$file"
        else
            echo "$file(无需处理,因为不是git项目)"
        fi
    fi
done
echo 处理结束,按任意键退出
read -n 1
echo 退出

2.执行脚本

法1:直接双击git_config.sh

此时一般是自动使用git bash来运行脚本

 

按任意键可以退出执行 

法2:到tmp目录下=> 右键=> Git Bash Here

bash git_config.sh

git配置详述

配置方法

命令

作用

示例

git config [配置保存位置] [配置项] [配置值]

将某个配置项设置为指定值。

例:设置提交代码时的名字和邮箱。

git config --global user.name "Tony"

git config --global user.email "abc@qq.com"

[name]和[email address]加不加引号都可以。

这两项不会用于信息验证,可任意设置。

若邮箱与账号邮箱一样,则commits显示此邮箱的账号。

git config -l [配置保存位置]

//git config --list [配置保存位置]

显示当前配置。(按q键退出)

git config -e [配置保存位置]

用vi编辑.git/conf文件。

配置保存位置

英文

含义

配置保存文件

示例

--local

本地配置。默认

(当前目录).git/config

以user.name和user.email为例:

git config --local user.name "Tony"
git config --local user.email "abc@qq.com"

配置完后,会在.git/config生成如下内容:

[user]

    name = Tony

    email = abc@qq.com

--global

当前用户(全局)

C:\Users\xxx\.gitconfig

--system

所有用户(本系统)

$(prefix)/etc/gitconfig

--worktree

类似于--local

如果extensions.worktreeConfig存在,则读写.git/config.worktree。否则跟--local一样。

取消配置

命令

作用

示例

git config [配置保存位置] --unset [配置项]

删除某个配置。

例:删除提交代码时的名字和邮箱。

git config --global --unset user.name

git config --global --unset user.email

  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
-------- Picture To Icon --------------------------------- Picture To Icon converts images or your screen into icons, resizes the icon and extracts icons from libraries. Picture To Icon converts PNG, BMP, JPEG, GIF, CUR formats into multi-resolution Windows icons. You can capture your screen part and convert it to icon or BMP file. You can resize icon form 1x1 icon to 256x256 icon. All icon size below 256x256 are all supported by Picture To Icon. It's possible to convert 256-color icons into true color or any other color. icons in the exe, dll, ocx and other executable files can be extracted easily. Standard Features: - Convert BMP, JPEG, GIF, CUR, PNG, Screen part into icon. - Extract icon from exe, dll, ocx and other executable file. - Resize icon ( 1x1 to 256x256 ) - True color icons, XP icons, 256-color icons, 16-color icons, 2-color icons. - Single image icon file. - Multiple icons in one Windows icon file. - Transparent color icons. - User choused transparent color. - Image or icon resize to fit icon function. -------- Registration ------------------------------------ You are limited to 15 Days or 20 Times of use for an unregistered version. Picture is a shareware program. If you find it useful and continue to use it you are obligated to register it with the author by sending $29.95 Add $9.95 for CD, or free delivery if email/download. Order Page: http://www.exeicon.com/piture-to-icon/buy.htm -------- VISA/MASTERCARD/American Express Accepted --------- For VISA/MasterCard/American Express orders, include: 1) Name of card holder 2) Address of card holder 3) Name and address of user if different from card holder 4) Card #. 5) Expiration date of card -------- E-Mail Address ---------------------------------- Internet support: support@exeicon.com WWW: http://www.exeicon.com/piture-to-icon/ -------- Return Policy ---------------------------------- This program may be freely distributed provided it is unmodified, no charge is made for the software and it is distributed in the original ZIP or self installing EXE form. -------- Latest Version ---------------------------------- The latest version of Picture To Icon may be found in several places: The following www page: http://exeicon.com/ and http://www.exeicon.com/picture-to-icon

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT利刃出鞘

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值