void (@NotNull ProgressIndicator pi) { // Filter added files before further processing Map<VirtualFile, List<VirtualFile>> sortedFiles = GitUtil.sortFilesByGitRootIgnoringMissing(myProject, addedFiles); final HashSet<VirtualFile> retainedFiles = new HashSet<>(); for (Map.Entry<VirtualFile, List<VirtualFile>> e : sortedFiles.entrySet()) { VirtualFile root = e.getKey(); List<VirtualFile> files = e.getValue(); pi.setText(root.getPresentableUrl()); try { retainedFiles.addAll(Git.getInstance().untrackedFiles(myProject, root, files)); } catch (VcsException ex) { GitVcsConsoleWriter.getInstance(myProject).showMessage(ex.getMessage()); } } addedFiles.retainAll(retainedFiles); performAddingWithConfirmation(addedFiles, copyFromMap); }