private void commitsMenuCheckout() 
    {
        System.out.println("Enter the ID of the project to retrieve commits from.");
        ProjectsMenu projectsMenu = new ProjectsMenu(LOGGER, connection);
        projectsMenu.projectsMenuView();
        String input = userInput.nextLine();
        //check input
        InputChecker in = new InputChecker(input);
        if(in.hasAlpha()){
            System.out.println("That was not an int, returning to commits menu.");
            return;
        }
        int projectID = Integer.parseInt(input);

        ResultSet rs;
        //find commit to checkout
        commitsMenuView(projectID);
        
        System.out.println("Which commit would you like to checkout?");
        String commitIDToStopAt = userInput.nextLine();
               
        //find repository
        System.out.println("Enter the full path for the new repository");
        repositoryDir = userInput.nextLine();
        if(repositoryDir.trim().equals("")) {
            //set working directory
            repositoryDir = System.getProperty("user.dir");
        }
        

        // 4. get diffs up until that point
        try
        {
            Statement statement = connection.createStatement();
            if(commitIDToStopAt.trim().equals("")) {
                rs = statement.executeQuery("SELECT bodyOfDiff, fileAdjusted "
                    + "FROM commits INNER JOIN changes ON commits.ID = changes.commitID "
                    + "ORDER BY commits.id  ");
            } else {
                rs = statement.executeQuery("SELECT bodyOfDiff, fileAdjusted "
                    + "FROM commits INNER JOIN changes ON commits.ID = changes.commitID "
                    + "WHERE commits.id <= " + commitIDToStopAt
                    + " ORDER BY commits.id  ");
            }
        }
        catch (SQLException sqe)
        {
            LOGGER.log(Level.SEVERE, "Error getting diffs. Error: {0}", sqe.getMessage());
            System.out.println("There was an error in retrieving the Goal.");
            return;
        }            

        //apply diffs to make files
        HashMap<String, List<String> > patchesPerFile = new HashMap<>();
        try {
            while (rs.next())
            {
                String fileName = rs.getString("fileAdjusted");
                String p = rs.getString("bodyOfDiff");
                //System.out.println(fileName + " " + p);
                List<String> patchesListForThatFile = patchesPerFile.get(fileName);
                if (patchesListForThatFile == null) {
                    patchesListForThatFile = new ArrayList<>();
                    patchesPerFile.put(fileName, patchesListForThatFile);
                }
                patchesListForThatFile.add(p);
            }
        } catch (SQLException ex) {
            Logger.getLogger(CommitsMenu.class.getName()).log(Level.SEVERE, null, ex);
        }
        for ( Map.Entry<String, List<String> > entry : patchesPerFile.entrySet())
        {
            String fileName = entry.getKey();
            List<String> patches = entry.getValue();
            FileUtil.build(patches, repositoryDir + "/" + fileName);
        }
    }