1

I am using the org.eclipse.egit.github.core library (version 4.9.0.201710071750-r) and for the moment, I am able to push a list of files in a single commit.

I have for example packageA/myfile.xml and want to move it to packageB/myfile.xml.

I need to do it in a single commit and can be one of many operations (can be other new files, modified files).

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Carlos
  • 1,340
  • 1
  • 10
  • 26

1 Answers1

0

The library of choice to programmatically manipulate Git repositories with Java is JGit, a pure Java implementation of Git.

In the context of your question, you would

  1. move the file in question through the Java NIO/File API

  2. remove the old file (packageA/myfile.xml) with the JGit RmCommand

  3. add the moved file (packageB/myfile.xml) to the index with JGit's AddCommand

  4. commit the moved (actually removed and then (re-) added) file

The org.eclipse.egit.github.core plug-in/library that you mentioned is intended to interact with GitHub's REST API. It is used as the basis for the GitHub Eclipse integration, to access and query Git repositories hosted on GitHub review pul requests and similar things.

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79