新增:《为指定Git仓库单独配置用户名和邮箱》
This commit is contained in:
@@ -13,7 +13,6 @@ showComment: false
|
||||
<img src="https://readme-typing-svg.herokuapp.com?size=35&color=40B883¢er=true&vCenter=true&width=1000&lines=Hello%2C+welcome+to+my+page;My+web+name+is+Charles7c;I'm+currently+working+on+java+backend+development;My+motto:+“东隅已逝,桑榆非晚”;Thanks" alt="欢迎语" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div align="center">
|
||||
@@ -29,12 +28,12 @@ showComment: false
|
||||
<a href="https://blog.csdn.net/Charles_7c" target="_blank" style="display: inline-block;">
|
||||
<img src="https://img.shields.io/badge/CSDN-查尔斯-FC5531?logo=C&logoColor=FC5531" alt="CSDN个人主页" />
|
||||
</a>
|
||||
<a href="https://www.yuque.com/charles7c" target="_blank" style="display: inline-block;">
|
||||
<img src="https://img.shields.io/badge/语雀-查尔斯-38D27D" alt="语雀个人主页" />
|
||||
</a>
|
||||
<a href="https://juejin.cn/user/685744115170142" target="_blank" style="display: inline-block;">
|
||||
<img src="https://img.shields.io/badge/掘金-查尔斯-1E80FF" alt="掘金个人主页" />
|
||||
</a>
|
||||
<a href="https://www.yuque.com/charles7c" target="_blank" style="display: inline-block;">
|
||||
<img src="https://img.shields.io/badge/语雀-查尔斯-38D27D" alt="语雀个人主页" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
63
docs/categories/fragments/2022/03/28/为指定Git仓库单独配置用户名和邮箱.md
Normal file
63
docs/categories/fragments/2022/03/28/为指定Git仓库单独配置用户名和邮箱.md
Normal file
@@ -0,0 +1,63 @@
|
||||
---
|
||||
title: 为指定Git仓库单独配置用户名和邮箱
|
||||
author: 查尔斯
|
||||
date: 2022/03/28 21:29
|
||||
categories:
|
||||
- 杂碎逆袭史
|
||||
tags:
|
||||
- Git
|
||||
---
|
||||
|
||||
# 为指定Git仓库单独配置用户名和邮箱
|
||||
|
||||
## 前言
|
||||
|
||||
**C:** 在前几天里,笔者一直给大家分享关于如何在 Git 仓库中 “销赃匿迹”,究其原因是笔者最近业余时间用的是工作用笔记本来“干活”,工作用笔记本里的全局用户名和邮箱肯定是公司 GitLab 的信息了。
|
||||
|
||||
周末和工作日切换的时候,有时候兴致上来,没有及时修改全局用户名等信息,就直接 commit ,push 了,等到发现时那肯定就要用前几天的几个法子来挽救一下了。
|
||||
|
||||
可能会有同学问,你怎么不为指定仓库做一下局部用户名配置呢?是的,没错,有全局配置就会有局部配置,但笔者之所以还会出这种问题,主要有两点:
|
||||
|
||||
1. clone 了不知道多少个仓库,不是只在操作一个仓库的时候,每个都要配置,很是麻烦,直接一个全局配置搞定,多么简单
|
||||
2. 兴致上来,有一两个仓库就忘了配置
|
||||
|
||||
当然,如果后面笔者长期用工作用笔记本在业余时间“干活”的话,也完全可以将工作 Git 仓库们进行局部配置,毕竟相较来讲,工作仓库是稳定的。
|
||||
|
||||
闲话少说,下面贴一下为指定 Git 仓库做局部用户名和邮箱配置的方法。
|
||||
|
||||
## 全局配置用户名和邮箱
|
||||
|
||||
我们先一起回忆下全局配置用户名和邮箱的方法,在任意 Git 仓库里进行如下配置即可:
|
||||
|
||||
```shell
|
||||
# 全局配置用户名
|
||||
git config --global user.name "Charles7c"
|
||||
# 全局配置邮箱
|
||||
git config --global user.email "charles7c@126.com"
|
||||
```
|
||||
|
||||
## 局部配置用户名和邮箱
|
||||
|
||||
局部配置的方法也是非常简单,首先进入指定的 Git 仓库,然后进行如下配置即可:
|
||||
|
||||
```shell
|
||||
# 进入指定 Git 仓库
|
||||
cd HelloWorld
|
||||
# 局部配置用户名
|
||||
git config user.name "Charles7c"
|
||||
# 局部配置邮箱
|
||||
git config user.email "charles7c@126.com"
|
||||
```
|
||||
|
||||
没错,只需要在配置时去掉 `--global` 这个参数就可以了,配置完成后,你可以通过命令查看下配置是否成功。
|
||||
|
||||
::: tip 笔者说
|
||||
当然了,你也可以去其他没进行局部配置的仓库看看,看看它们的用户名和邮箱有没有受到影响。
|
||||
:::
|
||||
|
||||
```shell
|
||||
# 查看所在 Git 仓库配置的用户名
|
||||
git config user.name
|
||||
# 查看所在 Git 仓库配置的邮箱
|
||||
git config user.email
|
||||
```
|
Reference in New Issue
Block a user