Mar*_*bon 111 git github git-config gitolite
我使用我的个人笔记本电脑进行工作和个人项目,我想将我的工作电子邮件地址用于工作中的提交(gitolite)和我的个人电子邮件地址(github).
我读到了以下全球或临时解决方案:
git config --global user.email "bob@example.com"
git config user.email "bob@example.com"
git commit --author "Bob <bob@example.com>"
GIT_AUTHOR_EMAIL
,GIT_COMMITTER_EMAIL
或EMAIL
环境变量一种解决方案是手动运行shell函数,将我的环境设置为工作或个人,但我很确定我会经常忘记切换到正确的身份,导致提交错误的身份.
有没有办法将某个存储库,项目名称等绑定到身份(名称,电子邮件)?人们做什么?
Dan*_*Ray 127
git config user.email "bob@example.com"
在repo中执行该操作将在THAT repo上设置配置,而不是全局设置.
看起来这就是你所追求的,除非我误读你.
Mah*_*alt 37
您需要使用下面的本地set命令:
本地集
git config user.email mahmoud@company.ccc
git config user.name 'Mahmoud Zalt'
Run Code Online (Sandbox Code Playgroud)
本地得到
git config --get user.email
git config --get user.name
Run Code Online (Sandbox Code Playgroud)
本地配置文件位于项目目录中:.git/config
.
全球集
git config --global user.email mahmoud@zalt.me
git config --global user.name 'Mahmoud Zalt'
Run Code Online (Sandbox Code Playgroud)
全球化
git config --global --get user.email
git config --global --get user.name
Run Code Online (Sandbox Code Playgroud)
主目录中的全局配置文件:~/.gitconfig
.
记得引用空白等,例如:'FirstName LastName'
aru*_*net 22
使用".git"文件夹编辑配置文件以维护不同的用户名和电子邮件取决于存储库
[用户]
name = Bob
email = bob@example.com
以下命令显示为此存储库设置的用户名和电子邮件.
git config --get user.name
git config --get user.email
示例:对于我的配置文件在D:\ workspace\eclipse\ipchat\.git\config中
这里ipchat是我的回购名称
Set*_*son 16
如果您使用git config user.email "foo@example.com"
它将绑定到您当前的项目.
这就是我为我的项目所做的.我克隆/初始化repo时设置了适当的标识.这不是万无一失的(如果你在弄清楚之前忘记并推动你被冲洗了),但是如果你没有能力说出来它就会得到很好的效果git config --global user.email 'ILLEGAL_VALUE'
实际上,你可以制造非法的价值.设置你的git config --global user.name $(perl -e 'print "x"x968;')
然后,如果您忘记设置非全局值,您将收到错误消息.
[编辑]在另一个系统上,我不得不将x的数量增加到968,以使其失败并显示"致命:不可能长的个人识别码".相同版本的git.奇怪.
dra*_*788 10
从 Git 2.13 开始,您可以includeIf
在 gitconfig 中使用,根据运行 git 命令的存储库路径包含具有不同配置的文件。
自从 Ubuntu 18.04 附带一个足够新的 Git 以来,我一直~/.gitconfig
很高兴地使用它。
[include]
path = ~/.gitconfig.alias # I like to keep global aliases separate
path = ~/.gitconfig.defaultusername # can maybe leave values unset/empty to get warned if a below path didn't match
# If using multiple identities can use per path user/email
# The trailing / is VERY important, git won't apply the config to subdirectories without it
[includeIf "gitdir:~/projects/azure/"]
path = ~/.gitconfig.azure # user.name and user.email for Azure
[includeIf "gitdir:~/projects/gitlab/"]
path = ~/.gitconfig.gitlab # user.name and user.email for GitLab
[includeIf "gitdir:~/projects/foss/"]
path = ~/.gitconfig.github # user.name and user.email for GitHub
Run Code Online (Sandbox Code Playgroud)
https://motowilliams.com/conditional-includes-for-git-config#disqus_thread
要使用 Git 2.13,您需要添加 PPA(Ubuntu 18.04/Debian 之前的版本)或下载二进制文件并安装(Windows/其他 Linux)。
归档时间: |
|
查看次数: |
101843 次 |
最近记录: |