diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index e3530b19e040..7eda20eda687 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -231,8 +231,22 @@ class GitCheckoutOperation extends GitBranchOperation { private static void refresh(GitRepository... repositories) { for (GitRepository repository : repositories) { + // If repository is small, everything can happen so fast, that FileWatcher wouldn't report the change before refresh() handles it. + // Performing a fair total refresh would be an overhead, so just waiting a bit to let file watcher report the change. + // This is a hack, but other solutions would be either performance or programming overhead. + // See http://youtrack.jetbrains.com/issue/IDEA-80573 + sleepABit(); refreshRoot(repository); // repository state will be auto-updated with this VFS refresh => no need to call GitRepository#update(). } } + + private static void sleepABit() { + try { + Thread.sleep(50); + } + catch (InterruptedException e) { + throw new RuntimeException(e); + } + } }