diff --git a/BaseHandler.php b/BaseHandler.php
index d490a5967dd965c27b92a52c47aaf076835f60db..dfcee3d14845970653bb8422b93b7dd73eb5b27d 100644
--- a/BaseHandler.php
+++ b/BaseHandler.php
@@ -47,6 +47,11 @@ abstract class BaseHandler implements BaseHandlerInterface {
    */
   protected $drupalCorePackage;
 
+  /**
+   * @var string[]
+   */
+  protected $ignoredGitPatterns;
+
   /**
    * Handler constructor.
    *
@@ -129,4 +134,25 @@ abstract class BaseHandler implements BaseHandlerInterface {
     passthru(escapeshellcmd('git -c "user.email=composer@lakedrops.com" ' . $command));
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function gitIgnore($pattern) {
+    if ($this->ignoredGitPatterns === NULL) {
+      if (file_exists('.gitignore')) {
+        $this->ignoredGitPatterns = explode(PHP_EOL, file_get_contents('.gitignore'));
+      }
+      else {
+        $this->ignoredGitPatterns = [];
+      }
+    }
+
+    if (\in_array($pattern, $this->ignoredGitPatterns, TRUE)) {
+      return;
+    }
+
+    $this->ignoredGitPatterns[] = $pattern;
+    $this->git('ignore ' . $pattern);
+  }
+
 }
diff --git a/BaseHandlerInterface.php b/BaseHandlerInterface.php
index 7f485bb80af08f5d24e330dc701e0d1bcb00cb22..da60ee0b103c5b7bc8f1203ea53c500593881f5d 100644
--- a/BaseHandlerInterface.php
+++ b/BaseHandlerInterface.php
@@ -66,4 +66,12 @@ interface BaseHandlerInterface {
    */
   public function git($command);
 
+  /**
+   * Add the given pattern to gitignore if necessary.
+   *
+   * @param string $pattern
+   *   The pattern which should be ignored.
+   */
+  public function gitIgnore($pattern);
+
 }