// 2. Get branch/commit hash for the source repo - the actual source code
  @Test
  public void existsIn2() throws IOException {
    final String repo = "binrepo-devex";
    //  final String repo = "search_raptor_binary";
    // String githubUrl = "https://github.scm.corp.ebay.com/api/v3";
    // String accessToken = "1cf7d9792235b8592eda18bd7dcc2de37f99b3bc";

    final String path = "D:\\dev\\devex\\.binrepo-devex\\.git";

    File gitDir = new File(path);
    org.eclipse.jgit.lib.Repository repository =
        new org.eclipse.jgit.storage.file.FileRepository(gitDir);
    String branch = repository.getBranch();
    System.out.println("Branch=" + branch);
    final Map<String, Ref> allRefs = repository.getAllRefs();
    for (String s : allRefs.keySet()) {
      System.out.println("Here" + s);
    }

    RevWalk revWalk = new RevWalk(repository);
    ObjectId resolve = repository.resolve(Constants.HEAD);
    RevCommit commitRev = revWalk.parseCommit(resolve);
    String commitHash = commitRev.getName();
    System.out.println(commitHash + "\t" + commitRev.getFullMessage());

    Git binaryRepo = Git.open(gitDir);

    final ListBranchCommand listBranchCommand = binaryRepo.branchList();
    System.out.println(listBranchCommand.getRepository().getFullBranch());
    // get "status"
    final StatusCommand statusCommand = binaryRepo.status();
    Collection<String> toadd = GitUtils.getFilesToStage(statusCommand);
    for (String s : toadd) {
      System.out.println("To be added:" + s);
    }

    // add files to "staging"
    if (toadd.size() > 0) {
      AddCommand addCmd = binaryRepo.add();
      for (String file : toadd) {
        addCmd.addFilepattern(file);
      }

      try {
        addCmd.call();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    final StoredConfig config = repository.getConfig();
    String url = config.getString("remote", "origin", "url");
    if (url != null) {
      System.out.println("Origin comes from " + url);
    }

    // commit
    final CommitCommand commit = binaryRepo.commit();
    String msg = "Saving Repo:%s Branch:%s CommitHash:%s Time:%s";
    final String formattedMsg = String.format(msg, repo, branch, commitHash, new Date().toString());
    commit.setMessage(formattedMsg);
    try {
      commit.call();
    } catch (Exception e) {
      e.printStackTrace();
    }

    // push to origin now
    final PushCommand push = binaryRepo.push();
    final String remote = push.getRemote();
    System.out.println("Remote to push to:'" + remote + "'");
    try {
      push.call();
    } catch (Exception e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }