【问题标题】:gitconfig file in unexpected locationgitconfig 文件位于意外位置
【发布时间】:2016-10-01 07:26:44
【问题描述】:

我尝试像这样设置一个 git 别名:

git config --global alias.co checkout

但我收到以下错误:

error: could not lock config file /Users/[username]/.gitconfig: No such file or directory

当我ls -a 时,我看到.gitconfig 确实存在。

在进一步挖掘之后,我注意到~/.git 中有一个config 文件。打开此文件显示以下 git 设置:

[core]
      repositoryformatversion = 0
      filemode = true
      bare = false
      logallrefupdates = true
      ignorecase = true
      precomposeunicode = false
[user]
      name = [My Name]
      email = [my email address]

这应该是我放置我的 git 设置(例如别名)的地方吗?另外,为什么设置似乎驻留在此处而不是.gitconfig

【问题讨论】:

    标签: git bash command-line terminal


    【解决方案1】:

    首先,执行 git config -l --show-origin: 这将列出 git 为您的(系统、全局、本地)设置考虑的所有配置设置。

    其次,检查您的$HOME 值和您当前的ID:当前用户是否可以执行ls /Users/[username]?您的消息看起来不仅仅是权限问题。

    第三,~/.git/config 是在~ 完成的 git repo 的本地配置(就在您的全局 git 配置应该在的位置旁边)。
    我建议将 .git 文件夹移到别处,看看问题是否仍然存在,因为您可能不希望您的所有 $HOME 成为一个巨大的 git 存储库。

    【讨论】:

      猜你喜欢
      • 2021-03-19
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-19
      • 2016-12-21
      • 2019-08-30
      • 2018-04-29
      相关资源
      最近更新 更多