0

I have a git parent repository which contains a sub-module. Now I have modified few files which are available in the sub-module and few files in the parent module as well. My Goal is to push the changes using JGit API to the remote repository, so that both parent and sub-module would reflect my changes.

I can only able to commit and push the changes of the parent repository, whereas while pushing the sub-module changes the below exception is occurred:
"org.eclipse.jgit.api.errors.TransportException: Nothing to push."

Git submoduleGitObj = new Git(submoduleRepository)
submoduleGitObj.commit().setAuthor("testUser", "testUser@gmail.com").setAll(false)
      .setMessage(commitMessage).call(); // commit is successful
submoduleGitObj .push().setRemote("origin").setCredentialsProvider(credentialsProvider).call(); // throws exception and push is unsuccessful

Using JGit, I could be able to successfully commit and push the changes of both sub-module and the parent module

  • Not sure if remote names are case sensitive, but the default remote is named `origin` (lowercase). – Rüdiger Herrmann Sep 20 '19 at 07:54
  • Thanks for your response, it was a typo and the code snippet is corrected now. – karthick ravichandran Sep 20 '19 at 08:31
  • 1
    I think you are running into this: https://stackoverflow.com/questions/51496146/running-into-transportexception-nothing-to-push-when-pushing-changed-file-with. Submodules usually have a detached HEAD (i.e. HEAD does not point to a branch). To push commits you may need to specify a refspec like `HEAD:destination-branch`. – Rüdiger Herrmann Sep 20 '19 at 08:40
  • Possible duplicate of [Running into TransportException "Nothing to push" when pushing changed file with JGit](https://stackoverflow.com/questions/51496146/running-into-transportexception-nothing-to-push-when-pushing-changed-file-with) – Rüdiger Herrmann Sep 21 '19 at 07:54

0 Answers0