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 update-git-for-windows -y Popup #5255

Open
strongestgeek opened this issue Nov 13, 2024 · 2 comments
Open

Git update-git-for-windows -y Popup #5255

strongestgeek opened this issue Nov 13, 2024 · 2 comments

Comments

@strongestgeek
Copy link

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
  • 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.22631.4317]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: VIM
Custom Editor Path: 
Default Branch Option:  
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Install location: %USERPROFILE%\AppData\Local\Programs\Git\

Details

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

PowerShell 7

# Check if Git is installed and retrieve the current version
$gitPath = (Get-Command git -ErrorAction SilentlyContinue).Path

if (-not $gitPath) {
    Write-Output "Git is not installed on this system."
    exit
}

# Get the current Git version
$gitVersionOutput = git --version
$gitVersion = $gitVersionOutput -replace '[^\d\.]', '' # Strip non-numeric characters
$versionArray = $gitVersion.Split('.').ForEach{[int]$_} # Convert version to array of integers

# Define the Git update command based on version
if ($versionArray[0] -gt 2 -or ($versionArray[0] -eq 2 -and $versionArray[1] -gt 16) -or ($versionArray[0] -eq 2 -and $versionArray[1] -eq 16 -and $versionArray[2] -ge 1)) {
    # Git version is 2.16.1 or greater
    Write-Output "Git version is 2.16.1 or newer. Using 'git update-git-for-windows' command."
    & git update-git-for-windows -y /VERYSILENT
}
else {
    # Git version is 2.16.0 or earlier, and no update will be attempted
    Write-Output "Git version is 2.16.0 or earlier, which cannot be updated automatically with this script."
}

Write-Output "Git update process completed."
  • What did you expect to occur after running these commands?

Ok, so not an issue with more of a requested feature?
Long story short, we have hundreds of devices with Gt installed like this and we need a way to update them all silently. It would be nice if this works and no popups for the end users and I can deploy this script once a week or so just to check that devices are up to date.

  • What actually happened instead?

The end users get a popup box saying Git is installing and I know for a fact some will just close/cancel this and not let Git update.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

So I am only testing with an old version if I test with the latest version it won't try to update as it is the latest version.

@dscho
Copy link
Member

dscho commented Nov 14, 2024

The end users get a popup box saying Git is installing

Huh. https://jrsoftware.org/ishelp/index.php?topic=setupcmdline#VERYSILENT claims that the progress is suppressed.

But maybe it is the uninstall progress bar (Git for Windows' installer will uninstall any previous version it found before installing the current version, to ensure that there are no left-over files)? But no, the uninstaller is called with /VERYSILENT.

The uninstaller is actually called with more options: /VERYSILENT /SILENT /NORESTART /SUPPRESSMSGBOXES. Maybe the progress you see is suppressed when running the installer with all of those options?

Hmm. But now I see a problem:

& git update-git-for-windows -y /VERYSILENT

This assumes that update-git-for-windows supports a /VERYSILENT option, but it does not! It always starts the installed with /SILENT /NORESTART, and that's it.

@strongestgeek
Copy link
Author

Thank you for taking the time to look at this ticket. I have also been looking at it and found a better or maybe the correct way to do what I want.

So yes, I think trying to scrip this using & git update-git-for-windows -y /VERYSILENT (or /SILENT) is not the correct way but maybe a possible future feature that would be very nice?

Anyway, for anyone that finds this issue, I have the below solution.
Git-2.47.0.2-64-bit.exe /SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
This will update the application on the user's device, the command must be ran as the local user and not 'system' if the insall location is %LocalAppData%.

I have also worked out how we can detect when Git is installed to %LocalAppData%, uninstall is and reinstall it to "C:\Program Files\Git" so our system and manage and update Git all in one location.
You can see that script here.

@dscho, I am happy to mark this as closed if you are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants