public static void editAndCommitFile(final File file, final git4idea.repo.GitRepository repository, final Project project) throws IOException {
final VirtualFile readmeVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(file);
FileUtil.writeToFile(file, "\nnew line", true);
final LocalChangeListImpl localChangeList = LocalChangeListImpl.createEmptyChangeListImpl(project, "TestCommit", "12345");
final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(project);
VcsDirtyScopeManager.getInstance(project).markEverythingDirty();
changeListManager.ensureUpToDate(false);
changeListManager.addUnversionedFiles(localChangeList, ImmutableList.of(readmeVirtualFile));
final Change change = changeListManager.getChange(LocalFileSystem.getInstance().findFileByIoFile(file));
repository.getVcs().getCheckinEnvironment().commit(ImmutableList.of(change), COMMIT_MESSAGE);
}