Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 2

Git Trees Api

Hello All

I am here to ask how to rename directory through api

I have done with something reconstructing repo tree 

when create new tree if i send the base tree as empty string it clear old tree and their commits 

if i send the basetree it merge old tree with new tree 
how to solve this ?

1 Reply
Highlighted
Community Manager
Message 2 of 2

Re: Git Trees Api

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:

 

  1. 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
  2. Recursively walk up the tree creating new tree objects that point to the last new tree object until you reach `/`
  3. Create a new commit object that points to the new tree object for `/` and the parent commit
  4. 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.