powershell Powershell:删除Git工作树

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell Powershell:删除Git工作树相关的知识,希望对你有一定的参考价值。

# Description

Will delete all worktrees given as first argument. This can either be a simple string or an array as given in the example to delete multiple worktrees.

Note that due to path limitations in Microsoft Windows `Remove-Item` might fail for too deep paths.

# References

* [windows - How to delete directories with path/names too long for normal delete - Super User][superuser-2017-04-09]
* [powershell - Delete directory regardless of 260 char limit - Stack Overflow][stackoverflow-260-chars]
* [A Sysadmin • Powershell: Path length limitation][asysadmin-path-length]
* [Topic: Remove-Item: the specified path, file name are too long][powershell-path-length]
* Perhaps a workaround is to use `Get-ChildItem` as mentioned here: [How to quietly remove a directory with content in PowerShell - Stack Overflow][stackoverflow-remove-folder]

<!-- References -->

[stackoverflow-260-chars]: <https://stackoverflow.com/questions/16392765/delete-directory-regardless-of-260-char-limit> "powershell - Delete directory regardless of 260 char limit - Stack Overflow"
[asysadmin-path-length]: <http://asysadmin.tumblr.com/post/17654309496/powershell-path-length-limitation> "A Sysadmin • Powershell: Path length limitation"
[powershell-path-length]: <https://powershell.org/forums/topic/remove-item-the-specified-path-file-name-are-too-long/> "Topic: Remove-Item: the specified path, file name are too long"
[stackoverflow-remove-folder]: <https://stackoverflow.com/questions/7909167/how-to-quietly-remove-a-directory-with-content-in-powershell> "How to quietly remove a directory with content in PowerShell - Stack Overflow"
[superuser-2017-04-09]: <https://superuser.com/a/1122610> "windows - How to delete directories with path/names too long for normal delete - Super User"

@('feature-1', 'bug-2') |
  %{ $pattern = $_; $(
       git worktree list | %{ $_.Split()[0] } | Select-String $pattern
     )
   } |
  %{ Remove-Item -Recurse -Force $_ }; git worktree prune

以上是关于powershell Powershell:删除Git工作树的主要内容,如果未能解决你的问题,请参考以下文章

powershell 使用powershell #powershell从zip文件中删除文件

powershell 删除powershell中的交接点

powershell Powershell:删除Git工作树

powershell PowerShell删除Readonly

powershell Powershell:删除过时的本地Git跟踪分支

powershell 在Gac中安装/删除dll - Powershell