Git_Editor_Setup
Git Editor Setup
Configure your preferred text editor for Git.
π§ Set Default Editor
VS Code
git config --global core.editor "code --wait"
Sets VS Code as Git editor.
--waitmakes Git wait until file is closed.
VS Code Insiders
git config --global core.editor "code-insiders --wait"
Sets VS Code Insiders as Git editor.
Vim
git config --global core.editor "vim"
Sets Vim as Git editor.
Neovim
git config --global core.editor "nvim"
Sets Neovim as Git editor.
Nano
git config --global core.editor "nano"
Sets Nano as Git editor. Good for beginners.
Sublime Text
git config --global core.editor "subl -n -w"
Sets Sublime Text as Git editor.
Atom
git config --global core.editor "atom --wait"
Sets Atom as Git editor.
Notepad++ (Windows)
git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Sets Notepad++ as Git editor on Windows.
π Check Current Editor
git config --global core.editor
Shows your currently configured editor.
π Set Diff Tool
VS Code as Diff Tool
git config --global diff.tool vscode
Sets VS Code as the diff tool.
git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
Configures the VS Code diff command.
Use Diff Tool
git difftool
Opens diff in your configured diff tool.
Diff Without Prompt
git difftool -y
Opens diff without confirmation prompt.
π Set Merge Tool
VS Code as Merge Tool
git config --global merge.tool vscode
Sets VS Code as the merge tool.
git config --global mergetool.vscode.cmd 'code --wait $MERGED'
Configures the VS Code merge command.
Use Merge Tool
git mergetool
Opens merge conflicts in your configured merge tool.
Disable Backup Files
git config --global mergetool.keepBackup false
Prevents creating
.origbackup files after merge.
π Editor Workflow
graph LR
A[git commit] --> B{Has message?}
B -->|Yes -m| C[Create commit]
B -->|No| D[Open editor]
D --> E[Write message]
E --> F[Save & close]
F --> C
π» Editor for Rebase
During interactive rebase, editor opens with:
pick abc1234 First commit
pick def5678 Second commit
pick ghi9012 Third commit
Commands:
pick(p) - use commitreword(r) - use commit, edit messageedit(e) - use commit, pause for amendingsquash(s) - meld into previous commitdrop(d) - remove commit
β¨οΈ Editor Tips
Commit Message in Editor
Subject line (50 chars max)
Body text wraps at 72 characters. Explain
the what and why of the change, not the how.
Footer with references:
Closes #123
π Related
#git #editor #config #setup