【问题标题】:Git - bad config on line 69 in .gitconfigGit - .gitconfig 中第 69 行的错误配置
【发布时间】:2019-05-03 09:38:51
【问题描述】:

我开始学习 git,我正在制作文件夹到存储库。

在我需要初始化的文件夹中只有一个 index.html 和 app.js 没有别的。

我输入了:

$ git init

然后出现错误

致命:文件 /Users/matusrebros/.gitconfig 中的错误配置行 69

这是来自.gitconfig的行

    66 # Merge GitHub pull request on top of the current branch or,
    67 # if a branch name is specified, on top of the specified branch
    68 mpr = "!f() { \
    69
    70 # Detect whitespace errors when applying a patch
    71 whitespace = fix

在第 69 行,我什么都没有。

所以我需要使用命令 $ git init 将文件夹作为存储库。

【问题讨论】:

  • 第 68 行似乎突然结束了,很可能就是那一行。
  • 但错误说它在 69
  • 我明白这一点,但你能试着删除或编辑第 68 行,只是为了逗我开心?
  • 我怎样才能编辑它是好的?
  • 现在尝试删除它,第一步是确定问题的位置,然后您可以尝试修复它。因此,将文件复制到备份,删除该行,然后查看 git 是否满意。如果是,你知道它与那条线有关。然后从备份中恢复并继续进行故障排除。

标签: git macos


【解决方案1】:

根据您发布的 sn-p,.gitconfig 文件似乎来自此处:

https://github.com/mathiasbynens/dotfiles/blob/master/.gitconfig

您遇到错误的那部分文件丢失了一大段文本。它应该是这样的:

    # Merge GitHub pull request on top of the current branch or,
    # if a branch name is specified, on top of the specified branch
    mpr = "!f() { \
        declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \
        declare branch=\"${2:-$currentBranch}\"; \
        if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \
            git fetch origin refs/pull/$1/head:pr/$1 && \
            git checkout -B $branch && \
            git rebase $branch pr/$1 && \
            git checkout -B $branch && \
            git merge pr/$1 && \
            git branch -D pr/$1 && \
            git commit --amend -m \"$(git log -1 --pretty=%B)\n\nCloses #$1.\"; \
        fi \
    }; f"


[apply]

    # Detect whitespace errors when applying a patch
    whitespace = fix

如果您愿意,您可以将您的 .gitconfig 替换为我在上面发布的链接中的原件。或者,由于看起来 Lasse Vågsæther Karlsen 帮助您使其正常工作,您可以不用管它。

【讨论】:

    猜你喜欢
    • 2019-12-08
    • 1970-01-01
    • 2016-08-22
    • 2015-10-10
    • 1970-01-01
    • 2015-01-20
    • 2019-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多