sh.exe”: emacs: command not found (Git bash Windows)

I’m using Git Bash on Windows 7 and have a problem with setting up emacs as the default text editor – I’ve tried git config --global core.editor emacs, then git config --global core.editor "'C:/emacs-23.3/bin/runemacs.exe'", git config --global core.editor emacsclientw but to no avail. Each time I enter something like ’emacs README.txt’ in Bash, the below error shows:

sh.exe”: emacs: command not found

  • Bash/Shell Script Function to Verify Git Tag or Commit Exists and Has Been Pushed to Remote Repository
  • execute git command inside bash script
  • Git difftool not launching external DiffMerge program
  • How to check the validity of a remote git repository URL?
  • Mongod command not found (Windows7)(node.js)
  • Mac OSX prompt git branch aware
  • I’ve put up with this for the longest time, choosing to just open up emacs separately and opening up the related file, but this time I really want to set things up properly so that I can save time and simply invoke emacs from Git Bash. Does anyone know what I can do? Thanks in advance for your help.

  • Git on Windows: Where are my files?
  • How can I visualize per-character differences in a unified diff file?
  • dcommit only a certain local (i.e. git) branch with git-svn
  • Prevent people from pushing a git commit with a different author name?
  • Using the same deploy key for multiple github projects
  • How to change a git submodule to point to a subfolder?
  • 2 Solutions collect form web for “sh.exe”: emacs: command not found (Git bash Windows)”

    You need to ensure the emacs bin directory is on the PATH so that the binary can be found when just entering emacs or emacsclient. You can set the default editor for most unix type tool to use your current emacs session by setting the environment variable EDITOR to emacsclient. You should use emacsclient rather than emacsclientw because you need the launching tool to wait for the edit to be completed and they do that by waiting for the editor to exit. If you only want git to use this then git config --global core.editor emacsclient would do the job, or setting GIT_EDITOR=emacsclient in the environment.

    In summary:

    PATH=c:\emacs-23.3\bin;%PATH%
    EDITOR=emacsclient
    export PATH EDITOR
    

    or fix the equivalents in the Windows system environment.

    You can also try the magit, which is amazing to use Git in emacs.
    You can get it from https://github.com/magit/magit

    Git Baby is a git and github fan, let's start git clone.