简体   繁体   English

使用 PowerShell 创建/覆盖本地 repo 文件夹中的文件

[英]Create/Overwrite a file in a local repo folder using powerShell

I have a JSON file that I am updating in powershell and I want to create/overwrite that file in my local repo folder so I can commit it.我有一个要在 powershell 中更新的 JSON 文件,我想在我的本地 repo 文件夹中创建/覆盖该文件,以便我可以提交它。 I am trying to do this through powershell but I keep getting an error Permission denied.我正在尝试通过 powershell 执行此操作,但我不断收到错误权限被拒绝。 I do have access to that folder because it is on my local machine我确实可以访问该文件夹,因为它在我的本地机器上

Script脚本

$myJsonFile = $json | ConvertTo-Json -depth 100

New-Item -Path "C:\Desktop\Testing" -ItemType File -Value $myJsonFile

I cloned an empty repo inside that folder and now trying to create a file.我在该文件夹中克隆了一个空仓库,现在尝试创建一个文件。 What am I doing wrong?我究竟做错了什么?

您只需执行以下操作并添加文件名

$json | ConvertTo-Json -depth 100 | Out-File ""C:\Desktop\Testing\Test.json"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM