creating folders in remote repository using jgit
<p>I am using Jgit api. I am able to create files in git remote location using the cloneRepository method.  </p>

<p>Similarly I can add files using the addCommand. The requirement now is to create folders or update an existing folder with files in local and to push, commit the same to remote repository - <a href="https://github.com" rel="nofollow">https://github.com</a>. 
I tried modifying the same code that we use for creating a file, but it is not working.  </p>

<p>How can I achieve this?
Code used for adding a file: </p>

<pre><code>File file = new File(Trial.localPath + "\\" + fileName);
file.createNewFile();
UsernamePasswordCredentialsProvider upc = new UsernamePasswordCredentialsProvider(
                    userName, password);
git = Git.cloneRepository().setURI(remotePath).setDirectory(puppetDirFile).setCredentialsProvider(upc).call();
git.add().addFilepattern(fileName).call();  
git.commit().setMessage("Added "+ fileName).call();

PushCommand pc = git.push();
pc.setCredentialsProvider(upc).setForce(true).setPushAll();
pc.call();
git.getRepository().close();
</code></pre>

<p>modified for adding folder : </p>

<pre><code>File file = new File(Trial.localPath+"\\ProjectA");
        if (!file.exists()) {
            if (file.mkdir()) {
                System.out.println("Directory is created!");
            }
        }
git.add().addFilepattern("projectA").call();    
git.commit().setMessage("Added "+ "ProjectA").call();
</code></pre>

<p>then rest pushed as the same above code.</p>