diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 813539d62a90fa01ea909e17f68afc9cd6579226..d48d5805f26d9cca3b318eedef08401e2e43fc06 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -2467,8 +2467,11 @@ VcsBase::Command *GitClient::createCommand(const QString &workingDirectory,
     VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory, processEnvironment());
     command->setCodec(getSourceCodec(currentDocumentPath()));
     command->setCookie(QVariant(editorLineNumber));
-    if (editor)
-        connect(command, SIGNAL(finished(bool,int,QVariant)), editor, SLOT(commandFinishedGotoLine(bool,int,QVariant)));
+    if (editor) {
+        editor->setCommand(command);
+        connect(command, SIGNAL(finished(bool,int,QVariant)),
+                editor, SLOT(commandFinishedGotoLine(bool,int,QVariant)));
+    }
     if (useOutputToWindow) {
         command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
         command->addFlags(VcsBasePlugin::ShowSuccessMessage);
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 1d83c0ef8b125e3afcede8dcff185d00bf7e2687..feb4c5588bc78e53973af97f5ac965971102b611 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -143,6 +143,7 @@ void VcsBaseClientPrivate::saveSettings()
 
 void VcsBaseClientPrivate::bindCommandToEditor(Command *cmd, VcsBaseEditorWidget *editor)
 {
+    editor->setCommand(cmd);
     QObject::connect(cmd, SIGNAL(finished(bool,int,QVariant)), m_cmdFinishedMapper, SLOT(map()));
     m_cmdFinishedMapper->setMapping(cmd, editor);
 }
diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp
index 9141a4b620c92567954d9c3f919c0f281fc8c640..0c415cf8ebe7dff6f7695f043dd29c19148e500f 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.cpp
+++ b/src/plugins/vcsbase/vcsbaseeditor.cpp
@@ -32,6 +32,7 @@
 #include "baseannotationhighlighter.h"
 #include "vcsbaseplugin.h"
 #include "vcsbaseeditorparameterwidget.h"
+#include "command.h"
 
 #include <coreplugin/icore.h>
 #include <coreplugin/vcsmanager.h>
@@ -575,6 +576,7 @@ public:
     VcsBaseEditorParameterWidget *m_configurationWidget;
     bool m_mouseDragging;
     QList<AbstractTextCursorHandler *> m_textCursorHandlers;
+    QPointer<Command> m_command;
 
 private:
     QComboBox *m_entriesComboBox;
@@ -1350,6 +1352,13 @@ VcsBaseEditorParameterWidget *VcsBaseEditorWidget::configurationWidget() const
     return d->m_configurationWidget;
 }
 
+void VcsBaseEditorWidget::setCommand(Command *command)
+{
+    if (d->m_command)
+        d->m_command->abort();
+    d->m_command = command;
+}
+
 // Find the complete file from a diff relative specification.
 QString VcsBaseEditorWidget::findDiffFile(const QString &f) const
 {
diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h
index b2fd845d9ee0fe2eedad96480d97a01b572ce1f3..ae2587c88a91cbbc1bd24257bd5d806ecbc470dd 100644
--- a/src/plugins/vcsbase/vcsbaseeditor.h
+++ b/src/plugins/vcsbase/vcsbaseeditor.h
@@ -55,6 +55,7 @@ class VcsBaseEditorWidgetPrivate;
 class DiffHighlighter;
 class BaseAnnotationHighlighter;
 class VcsBaseEditorParameterWidget;
+class Command;
 
 // Documentation inside
 enum EditorContentType
@@ -188,6 +189,7 @@ public:
     bool setConfigurationWidget(VcsBaseEditorParameterWidget *w);
     VcsBaseEditorParameterWidget *configurationWidget() const;
 
+    void setCommand(Command *command);
     /* Tagging editors: Sometimes, an editor should be re-used, for example, when showing
      * a diff of the same file with different diff-options. In order to be able to find
      * the editor, they get a 'tag' containing type and parameters (dynamic property string). */