private final void reset(final Git gitSession) throws GitAPIException,
			IOException, InterruptedException {
		if (this.RESET.getValue()) {
			// set options to default
			this.GIT_URL_HTTPS.value(Config.getInstance().getValue(
					URL_HTTPS_KEY));
			this.main.flushConfig();
			this.USE_SSH.setValue(false);
			this.COMMIT.setValue(false);

			final ObjectId remoteHead;
			if (gitSession == null) {
				if (!this.repoRoot.exists() || this.repoRoot.delete()) {
					this.io.printError(
							"Reset failed\n"
									+ "The tool could not rebuild missing repo information",
							false);
					checkoutBand();
					reset(Git.open(this.repoRoot.toFile()));
				} else {
					this.io.printError("Reset failed", true);
				}
				return;
			}
			// remove lock
			this.repoRoot.resolve(".git", "index.lock").delete();

			gitSession
					.getRepository()
					.getConfig()
					.setString("remote", "origin", "url",
							this.GIT_URL_HTTPS.value());
			gitSession.getRepository().getConfig().save();
			final Set<String> refs = gitSession.getRepository().getAllRefs()
					.keySet();
			if (!refs.contains("refs/heads/" + this.BRANCH.value())) {
				this.io.printMessage("Specified branch missing in config",
						"Branch \"" + this.BRANCH.value()
								+ "\" does not exist.\n"
								+ "Resetting to default \"master\".", true);
				this.BRANCH.value("master");
				final InputStream in = this.io.openIn(this.repoRoot.resolve(
						".git", "HEAD").toFile());
				final String localHead;
				if (in == null) {
					localHead = "refs/heads/master";
					final OutputStream out = this.io.openOut(this.repoRoot
							.resolve(".git", "HEAD").toFile());
					out.write("ref: refs/heads/master");
					this.io.close(out);
				} else {
					localHead = in.readLine().replace("ref: ", "");
					this.io.close(in);
				}
				if (this.repoRoot.resolve(localHead.split("/")).exists()) {
					this.io.printError(
							"Reset failed\n"
									+ "The tool could not rebuild missing repository information",
							false);
					return;
				}
			}
			remoteHead = getRemoteHead(gitSession);


			// set to remote head
			this.io.startProgress("Checking out " + remoteHead.getName(), -1);
			gitSession.checkout().setName(remoteHead.getName().substring(0, 8))
					.call();
			this.io.startProgress("Resetting local to remote head", -1);
			gitSession.reset().setRef(remoteHead.getName())
					.setMode(ResetType.HARD).call();

			// remove possible old branches - active branch and the temporarily
			// branch
			gitSession.branchDelete().setForce(true)
					.setBranchNames(this.BRANCH.value(), tmpBranchName).call();

			// create and checkout active branch
			gitSession.branchCreate().setName(this.BRANCH.value()).call();
			gitSession.checkout().setName(this.BRANCH.value()).call();
			this.io.endProgress("Reset done");
		}
	}