my-notes

Git_Editor_Setup

1 min read

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. --wait makes 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 .orig backup 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 commit
  • reword (r) - use commit, edit message
  • edit (e) - use commit, pause for amending
  • squash (s) - meld into previous commit
  • drop (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


#git #editor #config #setup

Built with mdgarden