title: TeamCity stderr: fatal: Cannot switch branch to a non-commit
body: <p>A TeamCity pipeline randomly stopped working today, and it has an error I cannot seem to find elsewhere. When I run the build, it git clones all the files, but then fails on checkout. This checkout hash doesn't seem to exist, but cleaning the caches, rebooting the agent, and rebooting the server did not do the trick. Is there a git piece that I am missing, or possibly a way to clean this out of the build agent?</p>
  
  <pre><code>16:05:51
    Will use agent side checkout
  16:05:51
    Full checkout enforced. Reason: ["Delete all files before the build" turned on]
  16:05:51
    VCS Root: https://github.com/local-projects/pw.g7.teleprompt.unity (1)
  16:05:51
      revision: 783ea57115a3d7f5451073926548ad973a9ddb88
  16:05:51
      Git version: 2.24.0.0
  16:05:51
      Update git mirror (C:\BuildAgent\system\git\git-F24DA617.git)
  16:05:51
        "C:\Program Files\Git\bin\git.exe" init --bare
  16:05:51
        "C:\Program Files\Git\bin\git.exe" config http.sslCAInfo
  16:05:51
        "C:\Program Files\Git\bin\git.exe" config --unset http.sslCAInfo
  16:05:51
        "C:\Program Files\Git\bin\git.exe" show-ref refs/heads/develop
  16:05:51
              "C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass1816473220437508924.bat -c credential.helper= fetch --progress origin +refs/heads/develop:refs/heads/develop
  16:06:12
        "C:\Program Files\Git\bin\git.exe" log -n1 --pretty=format:%H%x20%s 783ea57115a3d7f5451073926548ad973a9ddb88 --
  16:06:12
        "C:\Program Files\Git\bin\git.exe" pack-refs --all
  16:06:12
      Update checkout directory (C:\BuildAgent\work\a887e2ee26f52a5b)
  16:06:12
        The .git directory is missing in 'C:\BuildAgent\work\a887e2ee26f52a5b'. Running 'git init'...
  16:06:12
        "C:\Program Files\Git\bin\git.exe" init
  16:06:12
        "C:\Program Files\Git\bin\git.exe" config lfs.storage C:\BuildAgent\system\git\git-F24DA617.git\lfs
  16:06:12
        "C:\Program Files\Git\bin\git.exe" config core.sparseCheckout true
  16:06:12
        "C:\Program Files\Git\bin\git.exe" config http.sslCAInfo
  16:06:12
        "C:\Program Files\Git\bin\git.exe" config --unset http.sslCAInfo
  16:06:12
        "C:\Program Files\Git\bin\git.exe" show-ref
  16:06:12
        "C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass4175147798534459759.bat -c credential.helper= ls-remote origin
  16:06:13
        "C:\Program Files\Git\bin\git.exe" show-ref refs/remotes/origin/develop
  16:06:13
        "C:\Program Files\Git\bin\git.exe" log -n1 --pretty=format:%H%x20%s 783ea57115a3d7f5451073926548ad973a9ddb88 --
  16:06:13
        "C:\Program Files\Git\bin\git.exe" branch
  16:06:13
        "C:\Program Files\Git\bin\git.exe" update-ref refs/heads/develop 783ea57115a3d7f5451073926548ad973a9ddb88
  16:06:13
        "C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass1212189670373603786.bat -c credential.helper= -c credential.helper=C:/BuildAgent/temp/buildTmp/credHelper1015436636057083148.bat checkout -q -f develop
  16:06:19
        "C:\Program Files\Git\bin\git.exe" branch --set-upstream-to=refs/remotes/origin/develop
  16:06:19
        Cleaning https://github.com/local-projects/pw.g7.teleprompt.unity (1) in C:\BuildAgent\work\a887e2ee26f52a5b the file set ALL_UNTRACKED
  16:06:19
        "C:\Program Files\Git\bin\git.exe" clean -f -d -x
  16:06:19
        Cleaning files in C:\BuildAgent\work\a887e2ee26f52a5b\Assets\StandardLibraries the file set ALL_UNTRACKED
  16:06:19
        "C:\Program Files\Git\bin\git.exe" clean -f -d -x
  16:06:19
        Checkout submodules in C:\BuildAgent\work\a887e2ee26f52a5b
  16:06:19
        "C:\Program Files\Git\bin\git.exe" submodule init
  16:06:20
        "C:\Program Files\Git\bin\git.exe" submodule sync
  16:06:21
        "C:\Program Files\Git\bin\git.exe" rev-parse HEAD
     "C:\Program Files\Git\bin\git.exe" ls-tree 783ea57115a3d7f5451073926548ad973a9ddb88 Assets/StandardLibraries
  16:06:21
        "C:\Program Files\Git\bin\git.exe" config remote.origin.url
  16:06:21
        Update git mirror (C:\BuildAgent\system\git\git-36C5F5B9.git) for submodule Assets/StandardLibraries
  16:06:21
          "C:\Program Files\Git\bin\git.exe" log -n1 --pretty=format:%H%x20%s b4ee5e1c0e6c605cb9c357376acbc97bc48e3ded --
  16:06:21
          "C:\Program Files\Git\bin\git.exe" init --bare
  16:06:21
          "C:\Program Files\Git\bin\git.exe" config http.sslCAInfo
  16:06:21
          "C:\Program Files\Git\bin\git.exe" config --unset http.sslCAInfo
  16:06:21
          "C:\Program Files\Git\bin\git.exe" show-ref refs/heads/*
  16:06:22
                  "C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass695126419434457207.bat -c credential.helper= fetch --progress origin +refs/heads/*:refs/heads/*
  16:06:24
          "C:\Program Files\Git\bin\git.exe" log -n1 --pretty=format:%H%x20%s b4ee5e1c0e6c605cb9c357376acbc97bc48e3ded --
  16:06:24
          "C:\Program Files\Git\bin\git.exe" pack-refs --all
  16:06:24
        "C:\Program Files\Git\bin\git.exe" init
  16:06:24
        "C:\Program Files\Git\bin\git.exe" config remote.origin.url https://tsuchodolski@github.com/local-projects/StandardLibraries.git
  16:06:24
        "C:\Program Files\Git\bin\git.exe" config lfs.storage C:\BuildAgent\system\git\git-36C5F5B9.git\lfs
  16:06:24
        "C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass1801536043500079705.bat -c credential.helper= -c credential.helper=C:/BuildAgent/temp/buildTmp/credHelper6734238235593565373.bat checkout -q -f b4ee5e1c0e6c605cb9c357376acbc97bc48e3ded
  16:06:24
    Failed to perform checkout on agent: '"C:\Program Files\Git\bin\git.exe" -c core.askpass=C:\BuildAgent\temp\buildTmp\pass1801536043500079705.bat -c credential.helper= -c credential.helper=C:/BuildAgent/temp/buildTmp/credHelper6734238235593565373.bat checkout -q -f b4ee5e1c0e6c605cb9c357376acbc97bc48e3ded' command failed.
  exit code: 128
  stderr: fatal: Cannot switch branch to a non-commit 'b4ee5e1c0e6c605cb9c357376acbc97bc48e3ded'
  </code></pre>