Using Sublime Text as your Git Editor

Real Python · Beginner ·🛠️ AI Tools & Apps ·9y ago

Key Takeaways

This video demonstrates how to configure Sublime Text as the Git editor, allowing users to write Git commit messages in Sublime Text when using the Git command line.

Full Transcript

hi there this is Daniel uh today I wanted to give you a quick demonstration of how you can use Sublime Text as your git editor um what that means is uh whenever you make a commit in git from the command line using the git command uh what will happen is that Sublime Text is going to pop up and you can actually edit your commit message within Sublime Text which um I found a lot more convenient because Sublime Tex is really the editor that uh I used the most that I'm the most comfortable with so naturally I wanted to use it for my git workflow as well and I'm going to show you real quick how that all works so what I'm going to do now is just uh jump into my shell here and um create a new git repository just an empty git repository and then um we also want to create uh some file.txt and uh maybe add some content content into that file all right so now we've got some file txt and um I'm going to add that file to git now I've got a new file some file txt and now uh the interesting bit here is that I'm going to configure git to use Sublime Text as my editor and the way you do that is is um by exporting a new um shell variable that is uh Gore editor and we set it to uh the suble command that will uh start or uh launch uh Sublime Text um and and make it the focused window and we'll tell it to wait um before it returns because that's necessary uh in the way the the git command wants to use the editor and it will also tell it to to create a new window because I found uh that's a little bit more convenient than just uh it opening a new tab so I'm going to run this which will uh create that new variable and uh git is going to reference that variable and then use Supply text as its editor so when I go and create a new commit now it uh is going to launch subblime text so as I hit return Sublime text pops up and we're in this temporary uh file here uh that's skit Sublime SL dogit commit edit message that's just a temporary file where our commit message is going to go into and then we can just say um hi there this is the initial commit right and it's going to ignore all of the commented out stuff here it's basically just going to take the first line and because of the way I've got my gutter set up here um it also Al tells me how much space I have left for a well formatted and well styled kid message so anyway I'm going to hit save here and then I just close that window by hitting command W or we could also click the x button here so what's happened now is that get um uh get notied that the suble command um exited now and um it created the commit just like we wanted so when I pull up git log I can actually see that commit here and we can see um that my text is in here as well just like I want it um just maybe uh a quick reminder you probably want to put this export command into your uh shell profile so that you don't have to enter it every single time and uh you want to make sure that your suble command is actually configured correctly right so you got to make sure that suble command uh exists and uh that's something that comes with Sublime Text but it's also something you need to configure or uh basically link up in your path and then you want to export that git editor variable all right that's all there is to it uh I hope that helped you out and uh talk to you soon

Original Description

► Optimize your Python + Sublime Text Setup: https://SublimeTextPython.com A quick tutorial on how to use Sublime Text as your Git editor. Enjoy! :) By configuring Sublime as your Git editor you can write your Git commit messages in Sublime Text if you use the Git command line. This is helpful if you don't want to be thrown into a Vim session every time you run `git commit` on OS X. ► Weekly Tips for Python Developers: https://dbader.org/newsletter
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Real Python · Real Python · 5 of 60

1 A better Python REPL – bpython vs python interpreter
A better Python REPL – bpython vs python interpreter
Real Python
2 Introducing large-type.com – A Utility Website
Introducing large-type.com – A Utility Website
Real Python
3 Reading Hacker News Without Wasting Tons of Time
Reading Hacker News Without Wasting Tons of Time
Real Python
4 Forward References and Python 3 Type Hints
Forward References and Python 3 Type Hints
Real Python
Using Sublime Text as your Git Editor
Using Sublime Text as your Git Editor
Real Python
6 Python Code Linting and Auto-Complete for Sublime Text
Python Code Linting and Auto-Complete for Sublime Text
Real Python
7 Make your Python Code More Readable with Custom Exceptions
Make your Python Code More Readable with Custom Exceptions
Real Python
8 Write Better Tests with Sublime Text's Split Layout Feature
Write Better Tests with Sublime Text's Split Layout Feature
Real Python
9 How to Use Sublime Text from the Command Line
How to Use Sublime Text from the Command Line
Real Python
10 Rename Variables with Multiple Selection in Sublime Text
Rename Variables with Multiple Selection in Sublime Text
Real Python
11 Sublime Text Settings for Writing PEP 8 Python
Sublime Text Settings for Writing PEP 8 Python
Real Python
12 Write Cleaner Python with Sublime Text's Indent Guides
Write Cleaner Python with Sublime Text's Indent Guides
Real Python
13 Sublime Text Whitespace Settings for Python Development
Sublime Text Whitespace Settings for Python Development
Real Python
14 Function Argument Unpacking in Python
Function Argument Unpacking in Python
Real Python
15 Python Code Review: Debugging and Refactoring "Conway's Game of Life" +  Automated Tests
Python Code Review: Debugging and Refactoring "Conway's Game of Life" + Automated Tests
Real Python
16 Using "get()" to Return a Default Value from a Python Dict
Using "get()" to Return a Default Value from a Python Dict
Real Python
17 A Python Shorthand for Swapping Two Variables
A Python Shorthand for Swapping Two Variables
Real Python
18 Python Code Review: Refactoring a Web Scraper, PEP 8 Style Guide Compliance, requirements.txt
Python Code Review: Refactoring a Web Scraper, PEP 8 Style Guide Compliance, requirements.txt
Real Python
19 Click & Jump to Test Failures from the Command Line (iTerm2)
Click & Jump to Test Failures from the Command Line (iTerm2)
Real Python
20 Setting up Sublime Text for Python Developers
Setting up Sublime Text for Python Developers
Real Python
21 Sublime Text + Python Guide Overview
Sublime Text + Python Guide Overview
Real Python
22 Python Code Review: Adding Pytest Tests to an Existing Python Web Scraper
Python Code Review: Adding Pytest Tests to an Existing Python Web Scraper
Real Python
23 Type-Checking Python Programs With Type Hints and mypy
Type-Checking Python Programs With Type Hints and mypy
Real Python
24 A Shorthand for Merging Dictionaries in Python 3.5+
A Shorthand for Merging Dictionaries in Python 3.5+
Real Python
25 Python Code Review Flask Web Security Tutorial + Virtualenvs, requirements.txt
Python Code Review Flask Web Security Tutorial + Virtualenvs, requirements.txt
Real Python
26 My Python Code Looks Ugly and Confusing – Help!
My Python Code Looks Ugly and Confusing – Help!
Real Python
27 Setting Up a Programmer Portfolio/Developer Blog – How To Get Started
Setting Up a Programmer Portfolio/Developer Blog – How To Get Started
Real Python
28 Do I Need a GitHub/GitLab/Bitbucket Profile as a Developer?
Do I Need a GitHub/GitLab/Bitbucket Profile as a Developer?
Real Python
29 Programmer Portfolio – Example and Walkthrough
Programmer Portfolio – Example and Walkthrough
Real Python
30 How to Get Your 1st Speaking Gig at a Tech Conference
How to Get Your 1st Speaking Gig at a Tech Conference
Real Python
31 How to Build Your Public Speaking Skills as a Developer
How to Build Your Public Speaking Skills as a Developer
Real Python
32 The Object-oriented Version of "Spaghetti Code" is "Lasagna Code" ?!
The Object-oriented Version of "Spaghetti Code" is "Lasagna Code" ?!
Real Python
33 Setting up Sublime Text for Python Developers – Lesson #1
Setting up Sublime Text for Python Developers – Lesson #1
Real Python
34 Cool New Features in Python 3.6
Cool New Features in Python 3.6
Real Python
35 "is" vs "==" in Python – What's the Difference? (And When to Use Each)
"is" vs "==" in Python – What's the Difference? (And When to Use Each)
Real Python
36 Emulating switch/case Statements in Python with Dictionaries
Emulating switch/case Statements in Python with Dictionaries
Real Python
37 Python Function Argument Unpacking Tutorial (* and ** Operators)
Python Function Argument Unpacking Tutorial (* and ** Operators)
Real Python
38 What Code Should I Put On My GitHub/GitLab/BitBucket Profile?
What Code Should I Put On My GitHub/GitLab/BitBucket Profile?
Real Python
39 A Crazy Python Dictionary Expression ?!
A Crazy Python Dictionary Expression ?!
Real Python
40 String Conversion in Python: When to Use __repr__ vs __str__
String Conversion in Python: When to Use __repr__ vs __str__
Real Python
41 Method Types in Python OOP: @classmethod, @staticmethod, and Instance Methods
Method Types in Python OOP: @classmethod, @staticmethod, and Instance Methods
Real Python
42 Optional Arguments in Python With *args and **kwargs
Optional Arguments in Python With *args and **kwargs
Real Python
43 Python Context Managers and the "with" Statement (__enter__ & __exit__)
Python Context Managers and the "with" Statement (__enter__ & __exit__)
Real Python
44 Installing Python Packages with pip and virtualenv / venv
Installing Python Packages with pip and virtualenv / venv
Real Python
45 "For Each" Loops in Python with enumerate() and range()
"For Each" Loops in Python with enumerate() and range()
Real Python
46 Python Code Review: LibreOffice Automation and the Python Standard Library
Python Code Review: LibreOffice Automation and the Python Standard Library
Real Python
47 Managing Python Dependencies With Pip and Virtual Environments – Lesson #1
Managing Python Dependencies With Pip and Virtual Environments – Lesson #1
Real Python
48 Python Tutorial: List Comprehensions Step-By-Step
Python Tutorial: List Comprehensions Step-By-Step
Real Python
49 Leveraging Python's Implicit "return None" Statements
Leveraging Python's Implicit "return None" Statements
Real Python
50 What's the meaning of underscores (_ & __) in Python variable names?
What's the meaning of underscores (_ & __) in Python variable names?
Real Python
51 Python Data Structures: Sets, Frozensets, and Multisets (Bags)
Python Data Structures: Sets, Frozensets, and Multisets (Bags)
Real Python
52 Writing automated tests for Python command-line apps and scripts
Writing automated tests for Python command-line apps and scripts
Real Python
53 How to find great Python packages on PyPI, the Python Package Repository
How to find great Python packages on PyPI, the Python Package Repository
Real Python
54 Immutable vs Mutable Objects in Python
Immutable vs Mutable Objects in Python
Real Python
55 PyPI vs Warehouse, the Next-Generation Python Package Repository
PyPI vs Warehouse, the Next-Generation Python Package Repository
Real Python
56 pep8.org — The Prettiest Way to View the PEP 8 Python Style Guide
pep8.org — The Prettiest Way to View the PEP 8 Python Style Guide
Real Python
57 My Experience at PyCon 2017 in Portland
My Experience at PyCon 2017 in Portland
Real Python
58 Pylint Tutorial – How to Write Clean Python
Pylint Tutorial – How to Write Clean Python
Real Python
59 "Reverse a List in Python" Tutorial: Three Methods & How-to Demos
"Reverse a List in Python" Tutorial: Three Methods & How-to Demos
Real Python
60 Python Refactoring: "while True" Infinite Loops & The "input" Function
Python Refactoring: "while True" Infinite Loops & The "input" Function
Real Python

This video teaches how to use Sublime Text as the Git editor, allowing for more convenient Git commit message writing. It covers configuring Sublime Text and setting up the necessary shell variables.

Key Takeaways
  1. Create a new Git repository
  2. Configure Sublime Text as the Git editor by exporting a shell variable
  3. Set the Gore editor variable to the Sublime Text command
  4. Create a new commit and edit the commit message in Sublime Text
  5. Save and close the Sublime Text window to create the commit
💡 Configuring Sublime Text as the Git editor can streamline the Git workflow and make it more convenient to write commit messages.

Related Reads

📰
The Only AI Tools a Small Business Actually Needs in 2026
Discover the essential AI tools for small businesses in 2026 to boost efficiency and customer engagement
Dev.to AI
📰
I Built an AI Life Planner the Month I Graduated and Switched to Linux Halfway Through
Learn how to build a personal AI life planner by following the author's journey, from initial development to switching to Linux halfway through, and apply these skills to your own projects
Dev.to · Hilal
📰
Your Second Brain Is a Graveyard. Your AI Has Amnesia. (Part 1)
Learn why your second brain and AI tools are failing you and how to address these issues
Medium · AI
📰
The Python Automation Business I Started With 200 Lines of Code Eventually Replaced My Freelance…
Learn how a simple 200-line Python script can turn into a full-fledged automation business, replacing freelance work
Medium · Programming
Up next
How AI Is Transforming Analytics in Tableau Cloud & Server
Salesforce Product Center
Watch →