- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试 Windows 上的 Git。我到了尝试“git commit”的地步,但我收到了这个错误:
Terminal is dumb but no VISUAL nor EDITOR defined. Please supply the message using either -m or -F option.
所以我发现我需要一个名为 EDITOR 的环境变量。没问题。我将它设置为指向记事本。这几乎奏效了。默认提交消息在记事本中打开。但是记事本不支持纯换行。我出去了Notepad++ ,但我无法弄清楚如何将 Notepad++ 设置为 %EDITOR%
,以便它按预期与 Git 一起工作。
我没有和 Notepad++ 结婚。在这一点上,我不介意我使用什么编辑器。我只是希望能够在编辑器中键入提交消息,而不是命令行(使用-m
)。
那些在 Windows 上使用 Git 的人:您使用什么工具来编辑您的提交消息,您必须做什么才能让它工作?
最佳答案
2015 年 9 月更新(6 年后)
last release of git-for-Windows (2.5.3)现在包括:
By configuring
git config core.editor notepad
, users can now usenotepad.exe
as their default editor.
Configuringgit config format.commitMessageColumns 72
will be picked up by the notepad wrapper and line-wrap the commit message after the user edits it.
参见 commit 69b301b通过 Johannes Schindelin (dscho
) .
而 Git 2.16 (Q1 2018) 会在生成编辑器时显示一条消息,告诉用户它正在等待用户完成编辑,以防编辑器打开一个 stash 的窗口或某处不起眼的地方,用户得到迷路了。
参见 commit abfb04d (2017 年 12 月 7 日),和 commit a64f213 (2017 年 11 月 29 日)Lars Schneider (larsxschneider
) .
帮助:Junio C Hamano (gitster
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 0c69a13 ,2017 年 12 月 19 日)
launch_editor()
: indicate that Git waits for user inputWhen a graphical
GIT_EDITOR
is spawned by a Git command that opens and waits for user input (e.g. "git rebase -i
"), then the editor window might be obscured by other windows.
The user might be left staring at the original Git terminal window without even realizing that s/he needs to interact with another window before Git can proceed. To this user Git appears hanging.Print a message that Git is waiting for editor input in the original terminal and get rid of it when the editor returns, if the terminal supports erasing the last line
原始答案
我刚刚用 git 版本 1.6.2.msysgit.0.186.gf7512 和 Notepad++5.3.1 测试了它
我希望不必必须设置一个 EDITOR 变量,所以我尝试了:
git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\""
# or
git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\" %*"
总是给出:
C:\prog\git>git config --global --edit
"c:\Program Files\Notepad++\notepad++.exe" %*: c:\Program Files\Notepad++\notepad++.exe: command not found
error: There was a problem with the editor '"c:\Program Files\Notepad++\notepad++.exe" %*'.
如果我定义一个 npp.bat 包括:
"c:\Program Files\Notepad++\notepad++.exe" %*
然后我输入:
C:\prog\git>git config --global core.editor C:\prog\git\npp.bat
它只适用于 DOS session ,但不适用于 git shell。
(不是说有了 core.editor 配置机制,里面有 "start/WAIT...
"的脚本不会工作,只会打开一个新的 DOS 窗口)
Bennett's answer提到避免添加脚本的可能性,而是直接引用程序本身 在简单引号之间。注意斜线的方向!使用 /
NOT \
来分隔路径名中的文件夹!
git config --global core.editor \
"'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
或者,如果您使用的是 64 位系统:
git config --global core.editor \
"'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
但我更喜欢使用脚本(见下文):这样我就可以使用不同的路径或不同的选项,而无需再次注册 git config
。
实际的解决方案(使用脚本)是要意识到:
你在配置文件中提到的实际上是一个shell(/bin/sh
)脚本,而不是DOS脚本。
那么起作用的是:
C:\prog\git>git config --global core.editor C:/prog/git/npp.bat
用 C:/prog/git/npp.bat
:
#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"
或
#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"
使用该设置,我可以从 DOS 或 Git Shell 执行“git config --global --edit
”,或者我可以执行“git rebase -i ...
' 来自 DOS 或 Git Shell。
机器人命令将触发一个新的 notepad++ 实例(因此有 -multiInst
' 选项),并等待该实例关闭后再继续。
请注意,我只使用'/',而不是\
'。而我installed msysgit using option 2. (将git\bin
目录添加到PATH
环境变量中,但不要覆盖一些内置的windows工具)
notepad++ 包装器名为 .bat 的事实并不重要。
最好将其命名为“npp.sh”并将其放在 [git]\cmd
目录中(或在您的 PATH 环境变量引用的任何目录中)。
另见:
lightfire228添加 in the comments :
For anyone having an issue where N++ just opens a blank file, and git doesn't take your commit message, see "Aborting commit due to empty message": change your
.bat
or.sh
file to say:
"<path-to-n++" .git/COMMIT_EDITMSG -<arguments>.
That will tell notepad++ to open the temp commit file, rather than a blank new one.
关于windows - 如何设置编辑器以在 Windows 上使用 Git?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10564/
这个问题已经有答案了: Is there any way to accept only numeric values in a JTextField? (20 个回答) It's possible i
我使用戴尔 XPS M1710。笔记本电脑的盖子、侧面扬声器和前置扬声器都有灯(3 组灯可以单独调节)和鼠标垫下方的灯。在 BIOS 中,我可以更改这些灯的颜色,至少是每个组。另外,我可以在鼠标垫下打
我知道我可以使用 在 iOS 5 中打开设置应用 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"
我有一个 Django 应用程序,我正在尝试为其设置文档。目录结构如下: - doc - project | - manage.py 我已经设置了路径以便 Sphinx 可以看到东西,但是当我尝试使用
我正在使用 768mb ram 运行 centos 5.5。我一直在日志中获取 server reached MaxClients setting, consider raising the MaxC
我在具有以下配置的服务器内运行了 Drupal 安装: StartServers 5 MinSpareServers 5 MaxSpareServers 15 MaxClien
是否可以使用 Microsoft.Web.Administration 包为给定的 location 配置 asp 设置? 我想以编程方式将以下部分添加到本地 IIS applicationHost.
我一直在阅读为 kube-proxy 提供参数的文档,但没有解释应该如何使用这些参数。我使用 az aks create 创建我的集群使用 azure-cli 程序,然后我获得凭据并使用 kubect
我想知道与在 PHP 中使用 setcookie() 函数相比,在客户端通过 JavaScript 设置一些 cookie 是否有任何明显的优势?我能想到的唯一原因是减少一些网络流量(第一次)。但不是
我有一个按钮可以将 body class 设置为 .blackout 我正在使用 js-cookie设置cookie,下面的代码与我的按钮相关联。 $('#boToggle').on('click'
我有一堆自定义的 HTML div。我将其中的 3 存储在具有 slide 类的 div 中。然后,我使用该幻灯片类调用 slick 函数并应用如下设置: $('.slide').slick({
我正在创建一个应该在 Windows 8(桌面)上运行的应用 我需要: 允许用户使用我的应用启动“文件历史记录”。我需要找到打开“文件历史记录”的命令行。 我需要能够显示“文件历史记录”的当前设置。
我刚买了一台新的 MacBook Pro,并尝试在系统中设置 RVM。我安装了 RVM 并将默认设置为 ➜ rvm list default Default Ruby (for new shells)
由于有关 Firestore 中时间戳行为即将发生变化的警告,我正在尝试更改我的应用的初始化代码。 The behavior for Date objects stored in Firestore
在 ICS 中,网络 -> 数据使用设置屏幕中现在有“限制后台数据”设置。 有没有办法以编程方式为我的应用程序设置“限制后台数据”? 或 有没有办法为我的应用程序调出具有选项的“数据使用”设置? 最佳
我正在尝试使用 NextJS 应用程序设置 Jest,目前在 jest.config.js : module.exports = { testPathIgnorePatterns: ["/.n
我最近升级到 FlashDevelop 4,这当然已经将我之前的所有设置恢复到原来的状态。 我遇到的问题是我无法在新设置窗口的哪个位置找到关闭它在方括号、大括号等之前插入的自动空格的选项。 即它会自动
有没有办法以编程方式访问 iPhone/iPod touch 设置? 谢谢。比兰奇 最佳答案 大多数用户设置可以通过读取存储在 /User/Library/Preferences/ 中的属性列表来访问
删除某些值时,我需要选择哪些设置来维护有序队列。我创建了带有自动增量和主键的 id 的表。当我第一次插入值时,没问题。就像 1,2,3,4,5... 当删除某些值时,顺序会发生变化,例如 1,5,3.
我正在尝试设置示例 Symfony2 项目,如此处所示 http://symfony.com/doc/current/quick_tour/the_big_picture.html 在访问 confi
我是一名优秀的程序员,十分优秀!