diff --git a/Makefile b/Makefile
index b819d41cfb67..070c540509cf 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,7 @@ DOCKER_BUILD = docker build --no-cache \
 	    -f slave.mk \
 	    PLATFORM=$(PLATFORM) \
 	    SKU=$(SKU) \
+	    DEBUG_BUILD=$(DEBUG_BUILD) \
 	    $@
 
 sonic-slave-build :
diff --git a/build_image.sh b/build_image.sh
index 5373b8da72c1..0954e61b25f5 100755
--- a/build_image.sh
+++ b/build_image.sh
@@ -13,11 +13,15 @@
 }
 
 ## Retrieval short version of Git revision hash for partition metadata
-[ -z "$(git status --untracked-files=no -s --ignore-submodules)" ] || {
-    echo "Error: There is local changes not committed to git repo. Cannot get a revision hash for partition metadata."
+if [ -z "$(git status --untracked-files=no -s --ignore-submodules)" ]; then 
+    GIT_REVISION=$(git rev-parse --short HEAD)
+elif [ ! "$DEBUG_BUILD" = "y" ]; then
+    echo "Error: There are local changes not committed to git repo. Cannot get a revision hash for partition metadata."
     exit 1
-}
-GIT_REVISION=$(git rev-parse --short HEAD)
+else 
+    echo "Warning: There are local changes not committed to git repo, revision hash won't be tracked. Never deploy this image for other than debugging purpose."
+    GIT_REVISION=$(git rev-parse --short HEAD)"_local_debug"
+fi
 
 mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
 sudo rm -f $OUTPUT_ONIE_IMAGE
diff --git a/rules/config b/rules/config
index d76477ce5adc..142a7c0d10f7 100644
--- a/rules/config
+++ b/rules/config
@@ -11,6 +11,10 @@
 # Uncomment next line to enable:
 # SONIC_CONFIG_PRINT_DEPENDENCIES = y
 
+# DEBUG_BUILD - enable building image with uncommitted local changes.
+# Uncomment next line to enable:
+# DEBUG_BUILD = y
+
 # SONIC_CONFIG_BUILD_JOBS - set number of jobs for parallel build.
 # Corresponding -j argument will be passed to make command inside docker
 # container.
diff --git a/slave.mk b/slave.mk
index 485f8ff9206c..30a63f497a94 100644
--- a/slave.mk
+++ b/slave.mk
@@ -316,7 +316,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform
 	)
 
 	./build_debian.sh "$(USERNAME)" "$(shell perl -e 'print crypt("$(PASSWORD)", "salt"),"\n"')" $(LOG)
-	TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) ./build_image.sh $(LOG)
+	TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) DEBUG_BUILD=$(DEBUG_BUILD) ./build_image.sh $(LOG)
 
 	$(foreach docker, $($*_DOCKERS), \
 		rm $($(docker)_CONTAINER_NAME).sh