Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git for Windows Installer overwrites init.defaultBranch value in system gitconfig #4525

Closed
1 task done
luhansen-ms opened this issue Jul 27, 2023 · 0 comments
Closed
1 task done
Labels
Milestone

Comments

@luhansen-ms
Copy link

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.41.0.windows.3
cpu: x86_64
built from commit: 4a1821dfb0c2160a4fcc85d2845f095c54339578
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22621.1992]

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

CMD

# run this, or have Git installed as a prerequisite
.\Git-2.41.0.3-64-bit.exe /SUPPRESSMSGBOXES /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=assoc,assoc_sh /VSNOTICE=1 /o:PathOption=Cmd

# set init.defaultBranch to any custom value
git config --system init.defaultBranch mycustombranch

# this is the command that, when run, will override the value we just set for init.defaultBranch
.\Git-2.41.0.3-64-bit.exe /SUPPRESSMSGBOXES /VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=assoc,assoc_sh /VSNOTICE=1 /o:PathOption=Cmd
  • What did you expect to occur after running these commands?

The entries in C:\Program Files\Git\etc\gitconfig would not be modified.

  • What actually happened instead?

init.defaultBranch was overridden by the installer to be master. It was previously set to be mycustombranch.

This problem is reproducible with the command line flags I included above to make the installation "silent", as well as using the GUI installer.

This seems to be related to this part of the installer flow:
image

I suspect this part of the installer flow should factor in whether or not this value is already set in the --system level gitconfig.

To my knowledge, no other properties (e.g. pull.rebase, core.autocrlf, mycustom.setting) were modified or overridden during the installation.

@luhansen-ms luhansen-ms changed the title Git for Windows Installer overwrites init.defaultBranch Git for Windows Installer overwrites init.defaultBranch value in system gitconfig Aug 1, 2023
dscho added a commit to dscho/build-extra that referenced this issue Aug 6, 2023
When a user configures the default branch name manually, i.e. edits the
system config themselves, the Git for Windows installer currently resets
it to whatever was specified when running the installer previously.

This is inconsistent with the way other defaults are inferred from the
system config, say, `core.symlinks`.

Let's make it consistent by interpreting the current value of
`init.defaultBranch` (if configured).

This addresses git-for-windows/git#4525.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
github-actions bot pushed a commit to git-for-windows/build-extra that referenced this issue Aug 7, 2023
When `init.defaultBranch` is changed manually in the system config,
subsequent Git for Windows upgrades [would overwrite that
change](git-for-windows/git#4525). This has
been [fixed](#515).

Signed-off-by: gitforwindowshelper[bot] <gitforwindowshelper-bot@users.noreply.github.com>
@dscho dscho closed this as completed Aug 7, 2023
@dscho dscho added this to the Next release milestone Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants