Git: Custom editor opens blank file

I set up Sublime Text 2 as my default text editor when using Git on Mac.

In my .bash_profile I put export EDITOR="/usr/local/bin/sublime -w". Whenever I open a file in command line, it opens up as a blank file. After 2-3 attempts the file then shows information like it should.

Did I set up something incorrect?

Any help appreciated. Thanks.

  • Multiple git editors
  • Git core.editor on Mac OS X
  • How do I use Notepad++ (or other) with msysgit?
  • how to (unobtrusively) specify commit messages in your editor/ide
  • Text editor for Mac which uses git to save files
  • How can I tell if my editor is adding or removing newlines at the end of a file from the diff?
  • What is this editor opened by “git commit --amend” in Windows 10 cmd and how do I use it?
  • How to change the text editor in git to Sublime - currently git commit commands are opening in Notepad
  • One Solution collect form web for “Git: Custom editor opens blank file”

    This gist mentions:

    The -w doesn’t seem to be needed anymore; Actually adding it now inverses the way it worked.
    Adding it, makes the terminal command exit before editing the file in sublime
    Removing it, will properly make the sublime command to not exit until the file is closed.

    Can just use this now (with no Sublime version):

    ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime
    

    Check to see if /usr/local/bin is in your PATH: open ~/.zshrc

    Make sure it says:

    export PATH=/usr/local/bin:/example/other/dirs/
    

    Back in the terminal enter this to refresh the file: source ~/.zshrc

    Now you can type sublime to open up Sublime Text:

    • sublime . to open the current directory or
    • sublime some-file.txt to open the directory/file in Sublime Text.

    Now, to set Sublime Text as the default editor set the EDITOR environment variable:

    export EDITOR='sublime'
    
    Git Baby is a git and github fan, let's start git clone.