# 'git config --edit' unexpected behavior

2 messages from 2023-04-10 to 2023-04-10. Participants: Mervin Guy, Jeff King.
Thread: https://gitlist.dev/t/59572

## Mervin Guy, 2023-04-10 19:44

Subject: 'git config --edit' unexpected behavior
Message-ID: <0E8CDEA4-21CC-4CF1-809F-3FE37849ED47@mervin.works>
URL: https://gitlist.dev/e/0E8CDEA4-21CC-4CF1-809F-3FE37849ED47%40mervin.works

```
What did you do before the bug happened? (Steps to reproduce your issue)

- Changed my directory to a git-repo I was working on, using 'cd <directory_name>'. Then I ran 'git config --global -e'.

What did you expect to happen? (Expected behavior)

- I exepected the command to display my current-config file, with all settings included, in my editor.

What happened instead? (Actual behavior)

- My config-file was overwritten and displayed a default-setup message, the config-file was lost after this point.
  I experimented with different ways of activating the command, but they all led to an overwrite of the file.

What's different between what you expected and what actually happened?

- The config-file should've displayed as-was, and no overwrite should've occurred unless explicitly commanded.

Anything else you want to add:

- It should be noted that I've been updating my config-file manually, up until this point. When updating it, I used
 '[subsection] component' rather than 'subsection.component'.

[System Info]
git version: 2.40.0
cpu: i686
sizeof-long: 4
sizeof-size_t: 4
shell-path: /bin/sh
compiler info: gnuc: 12.2
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/ash


```

## Jeff King, 2023-04-10 20:18

Subject: Re: 'git config --edit' unexpected behavior
Message-ID: <20230410201853.GD104097@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20230410201853.GD104097%40coredump.intra.peff.net
In-Reply-To: <0E8CDEA4-21CC-4CF1-809F-3FE37849ED47@mervin.works>

```
On Mon, Apr 10, 2023 at 03:44:26PM -0400, Mervin Guy wrote:

> What did you do before the bug happened? (Steps to reproduce your issue)
> 
> - Changed my directory to a git-repo I was working on, using 'cd <directory_name>'. Then I ran 'git config --global -e'.
> 
> What did you expect to happen? (Expected behavior)
> 
> - I exepected the command to display my current-config file, with all settings included, in my editor.
> 
> What happened instead? (Actual behavior)
> 
> - My config-file was overwritten and displayed a default-setup message, the config-file was lost after this point.
>   I experimented with different ways of activating the command, but they all led to an overwrite of the file.

That's certainly unexpected. "git config --global -e" works fine for me.
And Git itself won't overwrite the file; it will run your editor with
the name of the file, and the editor is responsible for any writing.
Which editor are you trying to use? Can you try running with:

  GIT_TRACE=1 git config --global -e

which should show the editor command that Git runs.

-Peff

```
