Git配置个人和公司的提交信息,通过‘目录配置‘

git配置个人和公司的提交信息

一般公司的git的commit信息都是你的真实姓名+你的公司邮箱(公司规定)

但是你在做个人项目或者demo时,不想透露自己的真名或者其他信息(隐私保护)

于是我们可以通过配置多份gitconfig来区分 个人项目和公司项目

实现:

将个人项目和公司项目分开在两个目录下

对这个两个目录下的git提交做配置

扩展:

你可以配置多个目录下的git commit提交信息

只要把配置目录搞对就是了

it's up to you

~/.gitconfig

shell 复制代码
...
[includeIf "gitdir/i:~/Documents/Personal/"]
    path = ~/.gitconfig_personal

[includeIf "gitdir/i:~/Documents/Work/"]
    path = ~/.gitconfig_companyname

~/.gitconfig_personal

shell 复制代码
[user]
    name = Your Personal Name
    email = your_personal@email.com

~/.gitconfig_companyname

shell 复制代码
[user]
    name = Your Personal Name
    email = your_personal@email.com

查看

shell 复制代码
	git config -l  # 在项目目标下执行此命令 看是否正确配置
	git config --show-origin --get user.name  	# 看个人名称
	git config --show-origin --get user.email	# 看邮箱
相关推荐
不老刘10 小时前
Antigravity 的 New Worktree 模式:给 AI 代理一个安全的“平行工位”
人工智能·git·ai编程·antigravity
光谱SpectrAI11 小时前
Windows 也中招:Git Bash 和 Node 仍信任泄露的 eMudhra 证书
git
YIN_尹11 小时前
【git原理与使用】git初识与安装
大数据·git·elasticsearch
Leo_Mr16 小时前
Vue3 项目配置 Git 提交规范(企业通用方案:husky + commitlint + cz-git + lint-staged)
git
jyOverQ16 小时前
Git rebase 和 merge 有什么区别?什么时候该用哪个?
git
晗夜未央16 小时前
跨仓库 Skill 换台电脑就失效?用 Git remote 校验项目
人工智能·git·python
Lsetea16 小时前
Git访问HTTPS证书不受信任:用URL级sslCAInfo限定私有CA范围
git·https·开发工具·ssl证书·ca证书
এ慕ོ冬℘゜1 天前
Git 基础入门|和 SVN 对比 + 四大区域 + 常用命令详解
git·svn
DevLoom_1 天前
macOS 命令行 curl/git 报 SSL 证书错误?eMudhra 事件完整修复指南
git·macos·ssl
keyipatience1 天前
Git学习(4)Git分布式优势与实战配置全解析
git·学习