Lesson Completion
Back to course

Editor and Tooling

Beginner
7 minutes4.7Git

The Hook (The "Byte-Sized" Intro)

You type git commit and suddenly you're trapped in Vim. You don't know how to type. You don't know how to quit. Millions of developers have been there. The fix is one line: git config --global core.editor "code --wait". Set your editor once, and every Git operation that needs text input uses the tool you actually know.

📖 What is Editor and Tooling?

Git uses external tools for text editing (commit messages, rebase), diff viewing, and merge conflict resolution. You can configure which tools Git uses.

Conceptual Clarity

Configurable tools:

SettingWhat It ControlsDefault
core.editorCommit messages, rebase instructionsvi or $EDITOR
diff.toolVisual diff viewerNone (uses terminal diff)
merge.toolMerge conflict resolverNone (manual editing)

When Git opens your editor:

  • git commit (without -m)
  • git rebase -i (interactive rebase)
  • git merge (when writing merge commit message)
  • git tag -a (without -m)

Popular diff/merge tools:

ToolTypeConfig
VS CodeEditor + Diff + Mergecode --wait --diff
MeldDiff + Mergemeld
Beyond CompareDiff + Mergebcomp
VimdiffDiff + Mergevimdiff
opendiffDiff (macOS)opendiff

Real-Life Analogy

Using Git without configuring your editor is like being handed a toolbox in a foreign language. Everything works, but you can't read the labels. Setting your editor is choosing tools you already know.

Visual Architecture

flowchart LR GIT["git commit / rebase / merge"] --> EDITOR["📝 core.editor"] GIT --> DIFF["🔍 diff.tool"] GIT --> MERGE["🔧 merge.tool"] style GIT fill:#0f3460,stroke:#53d8fb,color:#53d8fb

Why It Matters

  • Productivity: The right editor makes commit messages and rebases fast.
  • Conflict resolution: Visual merge tools make resolving conflicts intuitive.
  • Onboarding: New team members shouldn't fight their tools.
  • Consistency: Once set, Git always uses your preferred tools.

Code

bash
# ─── Set your editor ─── git config --global core.editor "code --wait" # VS Code git config --global core.editor "vim" # Vim git config --global core.editor "nano" # Nano git config --global core.editor "subl -n -w" # Sublime # ─── Set diff tool ─── git config --global diff.tool vscode git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE' # ─── Set merge tool ─── git config --global merge.tool vscode git config --global mergetool.vscode.cmd 'code --wait $MERGED' # ─── Use your diff tool ─── git difftool HEAD~1 # Opens visual diff # ─── Use your merge tool during conflict ─── git mergetool # Opens visual merge resolver # ─── Suppress backup files from mergetool ─── git config --global mergetool.keepBackup false

Key Takeaways

  • Set core.editor to avoid being trapped in an unfamiliar editor.
  • Visual diff/merge tools make code review and conflict resolution much easier.
  • --wait flag is critical — it tells Git to wait until you close the editor.
  • Configure once globally; override per-repo if needed.

Interview Prep

  • Q: Why is --wait needed when setting VS Code as Git's editor? A: Without --wait, Git opens VS Code and immediately continues, treating the empty/unchanged file as the input. --wait tells Git to pause until you close the file in VS Code, giving you time to write your commit message.

  • Q: What is the difference between diff.tool and git diff? A: git diff shows diffs in the terminal. git difftool opens your configured visual diff tool (e.g., VS Code, Meld). The visual tool provides side-by-side comparison with syntax highlighting.

  • Q: How do you resolve merge conflicts with a visual tool? A: Set merge.tool in your config, then run git mergetool during a conflict. Git opens each conflicted file in your configured merge tool, where you can visually pick changes.

Topics Covered

Git ConfigurationTooling

Tags

#git#config#editor#tools

Last Updated

2026-02-13