用例
通过迭代文件夹所拥有的文件路径来复制文件夹及其使用fs.unlinkSync
git.remove
git.remove
git.add并提交。电流状态
git status时显示,标记为已删除。fs.copyFile(oldPath, newPath, async err => {
if (err)
return console.log(err)
// Delete the old file
await fs.unlinkSync(oldPath)
// Remove the old file from git index
await git.remove({
dir,
filepath: path.basename(oldPath)
}).catch(error => console.log(error))
})问题
filepath是行不通的,因为现在有两个同名的文件。期望解
在使用isomorphic-git命令时,它从索引中删除已删除的文件,并将复制的文件添加到暂存中,如何使用复制此功能?
发布于 2019-10-11 11:02:10
解决方案是将相对路径传递给filepath字段,以便将相对路径从存储库目录传递到文件。
await git.remove({
dir,
filepath: relativePath
}).catch(error => console.log(error))https://stackoverflow.com/questions/58230724
复制相似问题