git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.28k stars 2.51k forks source link

Enhancement: Add an option in installer to leave default editor unmodified when updating #1385

Closed p-lucero closed 6 years ago

p-lucero commented 6 years ago

I apologize for avoiding the standard issue template; it really doesn't fit here. My problem, in short, is this: I've configured Sublime Text 3 to be my default editor when using Git for Windows. The installer for Git for Windows 2.15.1.2 asks me to select a default editor used by Git. I would like to leave my default editor as Sublime Text 3, but there doesn't appear to be an option for that; anything that I choose would overwrite my current selection. I'm really not enthusiastic about having to fix my default editor every time that Git updates; is there any chance that you can work on adding an option to leave the default editor unchanged in the installer?

A screenshot of the screen that I have an issue with

dscho commented 6 years ago

I've configured Sublime Text 3 to be my default editor when using Git for Windows.

You configured this in your $HOME/.gitconfig, right? In other words, you override whatever system configuration there is. So you're safe.

Besides, the default (vim) is the default chosen by Git itself, i.e. the Git for Windows installer does not even configure anything if you choose that.

Does that address your concern?

p-lucero commented 6 years ago

Ah, I see; I assumed that the installer would itself edit my $HOME/.gitconfig, which is indeed preserved after install. My apologies for overreacting, that does indeed address my concern.

I do have a follow-up question, though: if this doesn't edit $HOME/.gitconfig, what does it edit, and why does whatever that is get overridden by $HOME/.gitconfig?

dscho commented 6 years ago

if this doesn't edit $HOME/.gitconfig, what does it edit,

It edits the "system config", i.e. C:\Program Files\Git\mingw64\etc\gitconfig.

and why does whatever that is get overridden by $HOME/.gitconfig?

Git has several sources for config settings, in a very strict hierarchy:

  1. C:\ProgramData\Git\config
  2. C:\Program Files\Git\mingw64\etc\gitconfig
  3. %USERPROFILE%\.gitconfig (actually %HOME%\.gitconfig, or if HOME does not exist, %HOMEDRIVE%%HOMEPATH%\.gitconfig and only if that does not exist, either, %USERPROFILE%\.gitconfig)
  4. .git\config in your repository (if the current directory is inside a Git worktree)
  5. the command-line option -c as in git -c user.email=override.my@email.com commit

There is another obscure one (inherited from Linux conventions) between 2 and 3, but in practice it does not matter on Windows. For more information, see the git-config help page (via git help config): https://github.com/git-for-windows/git/blob/5d5baf91824ec7750b103c8b7c4827ffac202feb/Documentation/git-config.txt#L231-L284