Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Update September 2015 (6 years later)</p> <p>The <a href="https://github.com/git-for-windows/git/releases/tag/v2.5.3.windows.1" rel="noreferrer">last release of git-for-Windows (2.5.3)</a> now includes:</p> <blockquote> <p>By configuring <strong><code>git config core.editor notepad</code></strong>, users <a href="https://github.com/git-for-windows/git/issues/381" rel="noreferrer">can now use <code>notepad.exe</code> as their default editor</a>.<br> Configuring <code>git config format.commitMessageColumns 72</code> will be picked up by the notepad wrapper and line-wrap the commit message after the user edits it.</p> </blockquote> <p>See <a href="https://github.com/git-for-windows/build-extra/commit/69b301bbd7c18226c63d83638991cb2b7f84fb64" rel="noreferrer">commit 69b301b</a> by <a href="https://github.com/dscho" rel="noreferrer">Johannes Schindelin (<code>dscho</code>)</a>.</p> <p>And Git 2.16 (Q1 2018) will show a message to tell the user that it is waiting for the user to finish editing when spawning an editor, in case the editor opens to a hidden window or somewhere obscure and the user gets lost.</p> <p>See <a href="https://github.com/git/git/commit/abfb04d0c74cde804c734015ff5868a88c84fb6f" rel="noreferrer">commit abfb04d</a> (07 Dec 2017), and <a href="https://github.com/git/git/commit/a64f213d3fa13fa01e582b6734fe7883ed975dc9" rel="noreferrer">commit a64f213</a> (29 Nov 2017) by <a href="https://github.com/larsxschneider" rel="noreferrer">Lars Schneider (<code>larsxschneider</code>)</a>.<br> Helped-by: <a href="https://github.com/gitster" rel="noreferrer">Junio C Hamano (<code>gitster</code>)</a>.<br> <sup>(Merged by <a href="https://github.com/gitster" rel="noreferrer">Junio C Hamano -- <code>gitster</code> --</a> in <a href="https://github.com/git/git/commit/0c69a132cb1adf0ce9f31e6631f89321e437cb76" rel="noreferrer">commit 0c69a13</a>, 19 Dec 2017)</sup></p> <blockquote> <h2><code>launch_editor()</code>: indicate that Git waits for user input</h2> <p>When a graphical <code>GIT_EDITOR</code> is spawned by a Git command that opens and waits for user input (e.g. "<code>git rebase -i</code>"), then the editor window might be obscured by other windows.<br> 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.</p> <p>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</p> </blockquote> <hr> <p>Original answer</p> <p>I just tested it with git version 1.6.2.msysgit.0.186.gf7512 and Notepad++5.3.1</p> <p>I prefer to <em>not</em> have to set an EDITOR variable, so I tried:</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\"" # or git config --global core.editor "\"c:\Program Files\Notepad++\notepad++.exe\" %*" </code></pre> <p>That always gives:</p> <pre><code>C:\prog\git&gt;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" %*'. </code></pre> <p>If I define a npp.bat including:</p> <pre><code>"c:\Program Files\Notepad++\notepad++.exe" %* </code></pre> <p>and I type:</p> <pre><code>C:\prog\git&gt;git config --global core.editor C:\prog\git\npp.bat </code></pre> <p>It just works from the DOS session, <strong>but not from the git shell</strong>.<br> (not that with the core.editor configuration mechanism, a script with "<code>start /WAIT...</code>" in it would not work, but only open a new DOS window)</p> <hr> <p><a href="https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows/1431003#1431003">Bennett's answer</a> mentions the possibility to avoid adding a script, but to reference directly the program itself <strong>between simple quotes</strong>. Note the direction of the slashes! Use <code>/</code> NOT <code>\</code> to separate folders in the path name!</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor \ "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" </code></pre> <p>Or if you are in a 64 bit system:</p> <pre class="lang-bash prettyprint-override"><code>git config --global core.editor \ "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin" </code></pre> <p>But I prefer using a script (see below): that way I can play with different paths or different options without having to register again a <code>git config</code>.</p> <hr> <p>The actual solution (with a script) was to realize that:<br> <strong>what you refer to in the config file is actually a shell (<code>/bin/sh</code>) script</strong>, not a DOS script.</p> <p>So what does work is:</p> <pre><code>C:\prog\git&gt;git config --global core.editor C:/prog/git/npp.bat </code></pre> <p>with <code>C:/prog/git/npp.bat</code>:</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*" </code></pre> <p>or</p> <pre class="lang-bash prettyprint-override"><code>#!/bin/sh "c:/Program Files/Notepad++/notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*" </code></pre> <p>With that setting, I can do '<code>git config --global --edit</code>' from DOS or Git Shell, or I can do '<code>git rebase -i ...</code>' from DOS or Git Shell.<br> Bot commands will trigger a new instance of notepad++ (hence the <code>-multiInst</code>' option), and wait for that instance to be closed before going on.</p> <p>Note that I use only '/', not <code>\</code>'. And I <a href="https://stackoverflow.com/questions/623518/msysgit-on-windows-what-should-i-be-aware-of-if-any">installed msysgit using option 2.</a> (Add the <code>git\bin</code> directory to the <code>PATH</code> environment variable, but without overriding some built-in windows tools)</p> <p>The fact that the notepad++ wrapper is called .bat is not important.<br> It would be better to name it 'npp.sh' and to put it in the <code>[git]\cmd</code> directory though (or in any directory referenced by your PATH environment variable).</p> <hr> <p>See also:</p> <ul> <li><a href="https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/255212#255212">How do I view ‘git diff’ output with visual diff program?</a> for the general theory</li> <li><a href="https://stackoverflow.com/questions/780425/how-do-i-setup-diffmerge-with-msysgit-gitk/783667#783667">How do I setup DiffMerge with msysgit / gitk?</a> for another example of external tool (DiffMerge, and WinMerge)</li> </ul> <hr> <p><a href="https://stackoverflow.com/users/2716305/lightfire228">lightfire228</a> adds <a href="https://stackoverflow.com/questions/10564/how-can-i-set-up-an-editor-to-work-with-git-on-windows/773973#comment74027740_773973">in the comments</a>:</p> <blockquote> <p>For anyone having an issue where N++ just opens a blank file, and git doesn't take your commit message, see "<a href="https://stackoverflow.com/q/30085970/6309">Aborting commit due to empty message</a>": change your <code>.bat</code> or <code>.sh</code> file to say:</p> </blockquote> <pre><code>"&lt;path-to-n++" .git/COMMIT_EDITMSG -&lt;arguments&gt;. </code></pre> <blockquote> <p>That will tell notepad++ to open the temp commit file, rather than a blank new one.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload