首页 > 解决方案 > Git本地配置不覆盖全局配置

问题描述

我有几个使用 Gitlab 和全局配置(默认)的项目,以及使用另一个 gitlab 帐户的本地每个项目配置。问题是我无法使用本地配置拉动项目,就好像始终考虑全局配置一样。

$ git config --global --list
user.name=myusername
user.email=myemail@mydomain.fr
filesystem.Oracle Corporation|1.8.0_162|/dev/disk1s1.timestampresolution=1001 milliseconds
filesystem.Oracle Corporation|1.8.0_162|/dev/disk1s1.minracythreshold=0 nanoseconds

$ git config --local --list
core.repositoryformatversion=0
core.filemode=true
core.logallrefupdates=true
core.precomposeunicode=true
remote.origin.url=https://gitlab.com/folder/project
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.master.rebase=false
user.name=myotherusername
user.email=myotheremail@myotherdomain.com

$ git pull
remote: The project you were looking for could not be found.
fatal: repository 'https://gitlab.com/folder/project.git/' not found

相反,使用全局 conf 的项目在另一个项目的目录中运行良好(使用全局配置):

$ git pull
warning: redirecting to https://gitlab.com/gitlabuser/gitlabproject.git/
Already up to date.

标签: gitgit-config

解决方案


推荐阅读