Not Possible to switch branch after –skip-worktree

I haven’t been able to find a neat solution to this, so I’m using a .bat file to run --no-skip-worktree on the affected files. I then stash, switch branch, stash apply, and then use another .bat file to run --skip-worktree on the same files.

It’s not nice, but it’s the simplest and quickest way I’ve found so far.

Update:
I’ve run into this problem again so have created a PowerShell script instead of the .bat file mentioned above. It will prompt the user whether they want to skip or no-skip the files. Update the two parameters and you’re ready to go:

[string]$repoPath = "C:\Fully\Qualified\Path"
[string[]]$filesToSkip = @(
    "Local/Path/To/File.txt",
    "Local/Path/To/OtherFile.txt"
)

$skipText = Read-Host -Prompt 'Skip files? (y/n)'
$skip = $skipText -like "y"
cd $repoPath
foreach ($file in $filesToSkip)
{
    if($skip)
    {
        Write-Host "Skipping" $file
        git update-index --skip-worktree $file
    }
    else
    {
        Write-Host "No-skipping" $file
        git update-index --no-skip-worktree $file
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)