WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Git · Intermediate · question 38 of 100

How do you configure Git to use a specific text editor or diff tool?

📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

By default, Git uses a built-in text editor (usually Vim or Emacs) for editing commit messages and other text files. However, you can configure Git to use a different text editor or diff tool of your choice.

Here’s how to configure Git to use a specific text editor:

Set the core.editor configuration variable to the path of the text editor you want to use.

    git config --global core.editor "nano"

This example sets the core.editor variable to use the Nano text editor.

Verify that the core.editor variable was set correctly using the git config command.

    git config --global core.editor
    nano

This example verifies that the core.editor variable is set to use the Nano text editor.

Here’s how to configure Git to use a specific diff tool:

Set the diff.tool configuration variable to the name of the diff tool you want to use.

    git config --global diff.tool "meld"

This example sets the diff.tool variable to use the Meld diff tool.

Set the difftool.prompt configuration variable to false to prevent Git from prompting you to confirm each diff.

    git config --global difftool.prompt false

Verify that the diff.tool variable was set correctly using the git config command.

    git config --global diff.tool
    meld

This example verifies that the diff.tool variable is set to use the Meld diff tool.

Use the git difftool command to open the diff tool.

    git difftool file.txt

This will open the Meld diff tool (in this example) to compare the changes in file.txt.

In summary, to configure Git to use a specific text editor, set the core.editor configuration variable to the path of the text editor you want to use. To configure Git to use a specific diff tool, set the diff.tool configuration variable to the name of the diff tool you want to use, and set the difftool.prompt variable to false to prevent Git from prompting you to confirm each diff. Then, use the git difftool command to open the diff tool.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Git interview — then scores it.
📞 Practice Git — free 15 min
📕 Buy this interview preparation book: 100 Git questions & answers — PDF + EPUB for $5

All 100 Git questions · All topics