【问题标题】:How to locate the git config file in Mac [duplicate]如何在 Mac 中找到 git 配置文件 [重复]
【发布时间】:2013-04-23 09:25:36
【问题描述】:

如标题所示,如何在 Mac 中找到 git 配置文件?不知道如何找到它。需要设置

git config --global http.postBuffer 524288000

需要一些指导才能找到它..

【问题讨论】:

  • 实际上有多个 git 配置文件,它们按层次结构工作:systemgloballocalworktreefile。从 gitlab 文档中查看此链接 git-scm.com/docs/git-config#FILES

标签: git macos


【解决方案1】:

全局 Git 配置文件在所有平台上存储在 $HOME/.gitconfig

但是,您可以简单地打开一个终端并执行git config,这会将适当的更改写入此文件。除非您特别想要,否则您不需要手动调整 .gitconfig

【讨论】:

  • 可以指定如何在mac上找到文件夹吗?需要更多帮助才能找到文件...
  • @lakesh 打开终端和echo $HOME
  • 输入 vim ~/.gitconfig
  • ~/.gitconfig 将不存在,除非你有一些配置。
    $ git config --global alias.s status $vim ~/.gitconfig `
  • 另一种可能的全局配置文件路径:~/.config/git/config
【解决方案2】:

问题的解决方法是:

  1. 找到 .gitconfig 文件

  2. [用户] 名称 = 1wQasdTeedFrsweXcs234saS56Scxs5423 电子邮件 = ankittanna@hotmail.com [凭据] 助手 = osxkeychain [网址“”] 代替 = git:// [网址“https://”] [网址“https://”] 而不是 = git://

会有一个空白 url="" 将其替换为 url="https://"

[user]
    name = 1wQasdTeedFrsweXcs234saS56Scxs5423
    email = ankittanna@hotmail.com
[credential]
    helper = osxkeychain
[url "https://"]
    insteadOf = git://
[url "https://"]
[url "https://"]
    insteadOf = git://

这会起作用:)

快乐鞠躬

【讨论】:

    【解决方案3】:

    我使用保存在 .bash_profile 中的这个函数,它对我很有用。

    function show_hidden () {
            { defaults write com.apple.finder AppleShowAllFiles $1; killall -HUP Finder; }
    }
    

    使用方法:

    show_hidden true|false 
    

    【讨论】:

    • 作为替代方法,您也可以这样做:** alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app' AND
      alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'。然后使用只需输入控制台:showFileshideFiles
    • 这对我有用 -> shift + ⌘ + .
    【解决方案4】:

    您无需查找该文件。

    只在终端上写这个指令:

    git config --global --edit
    

    【讨论】:

    • 这应该是最佳答案。当我的 gitconfig 已经存在时,输入 vim ~/.gitconfig 想要创建一个新文件
    • 这对我有用,因为 gitconfig 文件在 Mac 上不可见
    • @AskQ 也许你没有任何 gitconfig。您可以在 ~ 或开发路径中的任何其他位置创建文件 .gitconfig
    • 这不应该是最佳答案,因为它没有回答问题。
    • 这是一个很好的答案,我使用git config --system --edit 来查找系统配置的位置,在我的例子中是 /usr/local/etc/gitconfig。我没有想法去看那里。 (在 vim 中打开文件然后1 后跟control + g 显示文件的路径)
    猜你喜欢
    • 2022-07-06
    • 2021-10-06
    • 2012-11-08
    • 2018-01-25
    • 2020-11-09
    • 2016-06-11
    • 2011-04-07
    • 1970-01-01
    • 2011-04-06
    相关资源
    最近更新 更多