Skip to content

Instantly share code, notes, and snippets.

@mrw34
Last active October 7, 2015 20:27
Show Gist options
  • Save mrw34/3220552 to your computer and use it in GitHub Desktop.
Save mrw34/3220552 to your computer and use it in GitHub Desktop.
import java.io.File;
import java.util.UUID;
import org.eclipse.jgit.api.Git;
public class TestUnstash {
public static void main(String[] args) throws Exception {
File directory = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
directory.mkdir();
File.createTempFile("blank", null, directory);
Git git = new Git(Git.init().setDirectory(directory).call().getRepository());
git.add().addFilepattern(".").call();
git.commit().setMessage("").call();
File subdirectory = new File(directory, "folder");
subdirectory.mkdir();
File.createTempFile("blank", null, subdirectory);
git.add().addFilepattern(".").call();
git.stashCreate().call();
git.stashApply().call();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment