diff --git a/Library/Homebrew/dev-cmd/tests.rb b/Library/Homebrew/dev-cmd/tests.rb
index bf721db0c60b3472a878ff6f6fbf1c053990ac27..f26bfed4abd2c0bacf5853524f4464bc63877e3c 100644
--- a/Library/Homebrew/dev-cmd/tests.rb
+++ b/Library/Homebrew/dev-cmd/tests.rb
@@ -49,6 +49,10 @@ module Homebrew
       ENV["HOMEBREW_TEST_GENERIC_OS"] = "1" if args.generic?
       ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online?
 
+      # Avoid local configuration messing with tests e.g. git being configured
+      # to use GPG to sign by default
+      ENV["HOME"] = "#{HOMEBREW_LIBRARY_PATH}/test"
+
       if args.coverage?
         ENV["HOMEBREW_TESTS_COVERAGE"] = "1"
         FileUtils.rm_f "test/coverage/.resultset.json"