boolean () { try { if (GitUtil.hasLocalChanges(true, myProject, myRoot)) { return true; } } catch (VcsException e) { LOG.info("isSaveNeeded failed to check staging area", e); return true; } // git log --name-status master..origin/master String currentBranch = myBranchPair.getSource().getName(); String remoteBranch = myBranchPair.getTarget().getName(); try { GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot); if (repository == null) { LOG.error("Repository is null for root " + myRoot); return true; // fail safe } final Collection<String> remotelyChanged = GitUtil.getPathsDiffBetweenRefs(Git.getInstance(), repository, currentBranch, remoteBranch); final List<File> locallyChanged = myChangeListManager.getAffectedPaths(); for (final File localPath : locallyChanged) { if (ContainerUtil.exists(remotelyChanged, remotelyChangedPath -> FileUtil.pathsEqual(localPath.getPath(), remotelyChangedPath))) { // found a file which was changed locally and remotely => need to save return true; } } return false; } catch (VcsException e) { LOG.info("failed to get remotely changed files for " + currentBranch + ".." + remoteBranch, e); return true; // fail safe } }