Can i Delete Multiple Files in 1 commit Using GitHub API ? #128531
Unanswered
gparagioudakis
asked this question in
API and Webhooks
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Select Topic Area
Question
Body
I want to delete all the files and folders inside a directory. I`m using 2 different methods but neither works.
When i`m using the Delete Request endpoint it makes 1 commit per item and i got like 20 commits to my project
foreach (var item in itemsToDelete)
{
var deleteRequest = new DeleteFileRequest(commitMessage, item.Sha, _branch);
await client.Repository.Content.DeleteFile(_owner, _repo, item.Path, deleteRequest);
}
And when i`m using the tree method and setting .sha to null and content to "" (content and sha cant be null at the same time )
it just modifies and corrupts the files but dont delete them.
foreach (var item in itemsToDelete)
{
newTreeItems.Add(new Octokit.NewTreeItem
{
Content = "",
Path = item.Path,
Mode = Octokit.FileMode.File,
Type = Octokit.TreeType.Blob,
Sha = null
});
}
Beta Was this translation helpful? Give feedback.
All reactions