Skip to content

Instantly share code, notes, and snippets.

@simshaun
Last active August 6, 2021 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simshaun/a93de5c4b775e0c042fea0015fd52ee7 to your computer and use it in GitHub Desktop.
Save simshaun/a93de5c4b775e0c042fea0015fd52ee7 to your computer and use it in GitHub Desktop.
PowerShell git skip-worktree aliases
<#
Command: gitskipped
Description: List skipped files in git
Usage: gitskipped
#>
function gitskipped {
(git ls-files -v $args) -split "\r\n" | Select-String -Pattern '^S ' | ForEach-Object {
Write-Output $_.Line.Substring(2)
}
}
<#
Command: gitskip
Description: Mark file(s) as "skip-worktree" in git
Usage: gitskip .env
#>
function gitskip {
git update-index --skip-worktree $args
}
<#
Command: gitunskip
Description: Unmark file(s) as "skip-worktree" in git
Usage: gitunskip .env
#>
function gitunskip {
git update-index --no-skip-worktree $args
}
<#
Command: gitunskipall
Description: Unmark all skipped files in git
Usage: gitunskipall
#>
function gitunskipall {
$files = @((git ls-files -v $args) -split "\r\n" | Select-String -Pattern '^S ' | ForEach-Object { $_.Line.Substring(2) })
git update-index --no-skip-worktree $files
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment