@Before
  public void prepare() throws Exception {
    Repository childRepository = lookupRepository(childRepositoryFile);

    Repository repository = lookupRepository(repositoryFile);
    StoredConfig config = repository.getConfig();
    RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
    remoteConfig.addURI(new URIish(childRepository.getDirectory().getParentFile().toURI().toURL()));
    remoteConfig.addFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
    remoteConfig.update(config);

    config.setString(
        ConfigConstants.CONFIG_BRANCH_SECTION,
        "master",
        ConfigConstants.CONFIG_KEY_REMOTE,
        "origin");
    config.setString(
        ConfigConstants.CONFIG_BRANCH_SECTION,
        "master",
        ConfigConstants.CONFIG_KEY_MERGE,
        "refs/heads/master");
    config.save();

    FetchOperation fetchOperation = new FetchOperation(repository, remoteConfig, 60, false);
    fetchOperation.run(null);
  }
 /**
  * Fetches the source ref(s) (from the given ref spec(s)) from the given uri to the given
  * destination(s) (in the given ref spec(s)) to the given repository.
  *
  * @param uri the uri to fetch from
  * @param fetchRefsRefSpecs the references with the sources and destinations
  * @param repository the repository to fetch to
  * @param monitor the monitor to report progress to
  * @return
  * @throws InvocationTargetException
  * @throws CoreException
  */
 private static Collection<Ref> fetch(
     URIish uri, List<RefSpec> fetchRefsRefSpecs, Repository repository, IProgressMonitor monitor)
     throws InvocationTargetException, CoreException {
   FetchOperation fetch = new FetchOperation(repository, uri, fetchRefsRefSpecs, 10 * 1024, false);
   fetch.run(monitor);
   FetchResult result = fetch.getOperationResult();
   return result.getAdvertisedRefs();
 }