TortoiseGit modified sign (icon overlay) is not updating

前端 未结 15 2358
我在风中等你
我在风中等你 2021-01-30 08:29

I have made a small change in some code but TortoiseGit shows it as modified (red exclamation sign) although I have committed, pulled, pushed, but it stays. What should I do her

15条回答
  •  Happy的楠姐
    2021-01-30 08:42

    It's a known issue in TortoiseGit. It exists for years and will apparently never be fixed. I don't know whether it's because the TortoiseGit developer is unwilling or unable to do it. (I've also reported it before but can't find the issue anymore now.)

    Anyway, here's what I do to resolve it:

    git gc --prune=all --quiet
    

    It prunes the Git repository, repacking all those single object files, reducing the number of files in .git from up to tens of thousands to under 20, and probably improving the overall performance of Git operations.

    Sometimes Git does a light version of that on its own after a commit, but I've rarely ever seen this happen in years of daily use. So I just do it myself. This is also a great action to consider before making a backup of the system (see below).

    To make it easier, I've created a batch file git-gcall.cmd in an accessible path that calls the command shown above. I have to run it after virtually every single commit and after 2–3 seconds the icons update themselves. No killing involved. Just waking up TortoiseGit a bit harder to actually observe the repository and update its status.


    Here's a PowerShell script that runs this command in a set of configured directories recursively, if necessary, for use before making a backup. It can also be run on a regular basis, for example over night, to resolve this outdated icons issue in the background.

    gc-all-git.ps1:

    Write-Host "Packing Git repositories where necessary..."
    
    function Git-Gc($path)
    {
        cd $path
        Get-ChildItem . -Recurse -Hidden .git | Foreach-Object {
            cd $_.FullName
            if ((Get-ChildItem objects -File -Recurse).Count -gt 50)
            {
                cd ../
                Write-Host $(Get-Location).Path
                git gc --prune=all --quiet
            }
        }
    }
    
    Git-Gc C:\Source
    Git-Gc C:\xampp\htdocs
    

    Call it with the usual required accompanying batch file:

    gc-all-git.cmd:

    @echo off
    cd /d "%~dp0"
    %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy unrestricted -File gc-all-git.ps1
    exit /b %errorlevel%
    

提交回复
热议问题