Git Bash not using the source value specified in windows terminal settings

Solution 1:

Why did the profile using the source attribute work before?

The "source" attribute indicates either a "Dynamic Profile" or a "JSON Fragment Extension" for Windows Terminal. While JSON Fragment Extensions are a fairly new feature, at the time of this answer, the Microsoft doc for the "source" attribute still just mentions that they are used for dynamic profiles. So apologies that my previous take on this answer assumed that this was a Dynamic Profile.

Windows Terminal includes built-in generators for dynamic profiles for WSL (any installed distribution), PowerShell Core, and Azure (although this seems to be more of a static generator). You can find the generators in this directory of the source.

JSON Fragment Extensions are used for third-party applications such as Git Bash, which recently added this as a feature in their installer.

After you confirmed that Git Bash really was using the "source" attribute, I decided to try out the installer and confirm the use of the fragment extensions. As expected, I see the same thing you do in my settings.json Profiles (and in the Settings UI):

{
    "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
    "hidden": false,
    "name": "Git Bash",
    "source": "Git"
}

And in C:\ProgramData\Microsoft\Windows Terminal\Fragments\Git, I can see the actual extension (git-bash.json):

{
    "profiles": [
        {
          "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
           "name": "Git Bash",
           "commandline": "d:/winbin/development/Git/bin/bash.exe -i -l",
           "icon": "d:/winbin/development/Git/mingw64/share/git/git-for-windows.ico",
           "startingDirectory": "%USERPROFILE%"
        }
    ]
}

Why doesn't it work anymore?

I'm honestly not quite sure. The feature seems pretty robust, in my limited testing. The only way I could break it was to do something pathologic, like:

  • Edit the fragment itself (requiring UAC elevation), which would give a different error that you received.
  • Change the "guid" attribute manually
  • Manually deleting the fragment

Most anything else I tried was recoverable or expected:

  • Uninstalling Git for Windows -- Correctly removed the fragment. Windows Terminal was even smart enough to remove the empty parent folders on restart.

  • Deleting the profile itself in settings.json -- Because the fragment still exists, it is recreated automatically as soon as the changes are saved.