Making changes via the Git Data API is extremely complicated. Personally, I find it much easier to clone the repository, make the changes locally, commit them, then push the changes back to the remote repository, than to make the same changes using the Git Data API. But if you really want to rename a directory via the Git Data API, then I believe this is what you would have to do:
- Create a new tree object using the new name for the directory that points to all the same contents for the directory as the old tree object
- Recursively walk up the tree creating new tree objects that point to the last new tree object until you reach
- Create a new commit object that points to the new tree object for
/ and the parent commit
- Update the branch that you want the new commit to exist on to point to the new commit object created in step 3
You can see a similar example in this previous post I made.
I hope that helps.