I need to clone an existing git repository into an InMemoryRepository
, using JGit, change a file's content and push the changes back to the remote repository.
I couldn't find any examples of cloning a repository into an in-memory repository.
I tried this:
InMemoryRepository.Builder builder = new InMemoryRepository.Builder();
InMemoryRepository inm = builder.build();
Git.cloneRepository().setURI("git@[github_url].git").setDirectory(inm.getDirectory()).call();
Which resulted in an error:
'Destination path ".git" already exists and is not an empty directory'.
I checked the configuration options for InMemoryRepository.Builder
and Repository
classes, but haven't found anything useful.
How can it be done? And after that, is there any problem with changing a file's content and pushing it to github, all from the in-memory repository?