Skip to content

Instantly share code, notes, and snippets.

@geekmanager
Last active May 7, 2025 12:34
Show Gist options
  • Select an option

  • Save geekmanager/9939cf67598efd409bc7 to your computer and use it in GitHub Desktop.

Select an option

Save geekmanager/9939cf67598efd409bc7 to your computer and use it in GitHub Desktop.
Making git use Sublime Text for rebase etc

Making git use Sublime Text

First up, let's make Sublime Text 2 available from the command line in terminal, by creating a link to subl which is the launcher from terminal:

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

(added bonus of this approach is when you upgrade to ST3 or change text editor, you can just redirect the symlink).

If there's any chance that bash doesn't check usr/local/bin then use Launch Sublime Text 2 from Mac OSX Terminal for more detailed instructions on how to make this happen.

Now tell git to use sublime:

git config --global core.editor "sublime -n -w"

(the -n = new window; -w = wait for file to be closed before returning. If you don't use the latter option, Sublime doesn't actually let you edit before returning to the in process git rebase or similar.)

Et voila, from now on when you do a rebase or similar, it should open in Sublime Text.

Sources

@niahoo

niahoo commented Jul 31, 2017

Copy link
Copy Markdown

Hey thanks, that is really useful !

@tuyenvx-1133

tuyenvx-1133 commented Apr 4, 2018

Copy link
Copy Markdown

Thank you !

@dinesh16

Copy link
Copy Markdown

👍

@laurajayneharvey

Copy link
Copy Markdown

Thanks!

@radekwilczak

Copy link
Copy Markdown

Thank you!

@warpling

warpling commented Mar 5, 2021

Copy link
Copy Markdown

THANK YOU

@mightbesimon

Copy link
Copy Markdown

Cheers mate

@maqboolkhan

Copy link
Copy Markdown

Thanks

@Nisim761

Nisim761 commented Jul 5, 2022

Copy link
Copy Markdown

i am getting this error message:

hint: Waiting for your editor to close the file... sublime -n -w: sublime: command not found
error: There was a problem with the editor 'sublime -n -w'.

@SkomantasVin

SkomantasVin commented Sep 20, 2022

Copy link
Copy Markdown

@Nisim761 This worked for me: git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl --new-window --wait"

Fore reference, recommendation about configuration found on git documentation

@mmontag

mmontag commented Apr 12, 2025

Copy link
Copy Markdown

if you just need it for a one-time complicated edit... GIT_EDITOR='subl -n -w' git rebase -i

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment