Git默认编辑器配置

时间:2019-05-24 11:15:35

标签: git

在Powershell中工作,我的主要目标是从协作者那里还原合并。

当我运行git revert -m 1 <SHA of merge>时 git返回:

hint: Waiting for your editor to close the file... C:\Users\Hugh\emacs\bin\runemacs.exe: 
C:UsersHughemacsbinrunemacs.exe: command not found
error: There was a problem with the editor 'C:\Users\Hugh\emacs\bin\runemacs.exe'.
Please supply the message using either -m or -F option.

我重新启动计算机并重新安装了存储库,但结果相同。

经过一番搜索,我决定尝试将默认编辑器从emacs更改为nano并运行:

git config --list

返回:

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
diff.astextplain.textconv=astextplain
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.smudge=git-lfs smudge -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.required=true
credential.helper=manager
core.editor=nano.exe
user.email=hghklly@gmail.com
user.name=Hugh
core.editor=C:\Users\Hugh\emacs\bin\runemacs.exe
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=git@github.com:ucfnmyo/SDC_MuseumsProject.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

您会看到core.editor有两个条目,nano.exe没有文件路径,而runemacs.exe的完整文件路径。

我检查了本地和全局配置文件,均未指定emacs。

C:/Program Files/Git/mingw64/etc/gitconfig上的配置内容:

[http]
    sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    sslBackend = openssl
[diff "astextplain"]
    textconv = astextplain
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[credential]
    helper = manager
[core]
    editor = nano.exe

本地配置内容:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = git@github.com:ucfnmyo/SDC_MuseumsProject.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

C:ProgramData/Git/config上的配置内容:

[core]
    symlinks = false
    autocrlf = true
    fscache = true
[color]
    diff = auto
    status = auto
    branch = auto
    interactive = true
[help]
    format = html
[rebase]
    autosquash = true

我还检查了Windows默认值,其中.txt文件是记事本。

关于(1)如何删除emacs作为默认git编辑器的任何建议,或(2)简单地如何解决此问题以恢复合并?

谢谢!

1 个答案:

答案 0 :(得分:2)

可以在三个地方配置Git:

  1. 系统
  2. 全球
  3. 本地

由于您已经检查了全局和本地,因此必须在系统配置中指定emacs编辑器。

如果您运行的是Windows XP以外的版本,则可以在C:\ProgramData\Git\config上打开此文件进行编辑。通常,您可以使用git config --edit --system之类的git命令,但是由于您的编辑器不同步,因此无法使用。

更新

要列出所有配置文件:git config --list --show-origin

然后,使用编辑器手动检查它们并删除重复的属性。