Git编辑器中缺少换行符(在Windows上使用记事本)

时间:2015-10-28 13:09:02

标签: git git-config

我一直在尝试将 notepad 设置为Git的默认全局编辑器。

调用记事本现在正常工作。这是我的配置文件的样子:

[
        {
            "id": 113548,
            "name": "Daventry",
            "state_id": 1446,
            "state_name": "Northamptonshire",
            "state_code": "J1",
            "country_id": 232,
            "country_name": "United Kingdom",
            "country_code": "GB",
            "country_flag": "GB.png",
            "currency_code": "GBP",
            "currency_symbol": "£"
        }
]

然而,当记事本启动时,例如使用[user] name = Gavin Hope email = gavin.hope@myemailaddress.com [core] autocrlf = true excludesfile = C:\\Users\\Gavin.Hope\\Documents\\gitignore_global.txt editor = 'C:\\Windows\\notepad.exe' [diff] tool = p4merge [merge] tool = p4merge [mergetool "p4merge"] path = C:/Program Files/Perforce/p4merge.exe keepBackup = false trustExitCode = false ,没有换行符。我明白这一点:

git commit

而不是(像某样):

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Date:      Wed Oct 28 11:40:40 2015 +0000## On branch playtime# Changes to be committed:#   modified:   file.xyz#

注1:这只是配置编辑器中换行符的问题,与# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Wed Oct 28 11:40:40 2015 +0000 # # On branch playtime # Changes to be committed: # modified: file.xyz# 有关的所有其他内容都可以。

注意2:在之前尝试配置编辑器(没有完全奏效)编辑器中的换行符是正常

我错过了autocrlf的参数或参数吗?我的配置中有什么问题吗?

2 个答案:

答案 0 :(得分:5)

如果您真的想使用notepad.exe,请查看GitPad

GitPad是一个围绕notepad.exe的包装器可执行文件,它接受git创建的提交文件并转换为Windows样式的行结尾。

答案 1 :(得分:2)

正如codeape所指出的,记事本不适合这项工作。

我已经切换到Notepad ++并且工作正常。因此,对于遇到相同问题或类似问题的其他人来说,这是明确的,这就是我的.gitconfig文件现在的样子:

[user]
    name = Gavin Hope
    email = gavin.hope@myemailaddress.com

[core]
    autocrlf = true
    excludesfile = C:\\Users\\Gavin.Hope\\Documents\\gitignore_global.txt
    editor = 'C:\\Program Files (x86)\\Notepad++\\notepad++.exe'

[diff]
    tool = p4merge

[merge]
    tool = p4merge

[mergetool "p4merge"]
    path = C:/Program Files/Perforce/p4merge.exe
    keepBackup = false
    trustExitCode = false