diff --git a/build.sh b/build.sh
index 52fd0691a464c4b11d3ae7c617a30b129fbcf7a8..27be85d8269629ecd220858a54538a0e0134b176 100755
--- a/build.sh
+++ b/build.sh
@@ -189,7 +189,7 @@ if [ "$1" == "setup" ]; then
 	cd ..
 
 	cd media-git
-	git remote add main $myrepo
+	git remote add $mybranch $myrepo
 	if [ -n "$mylocalrepo" ]; then
 		git remote add local $mylocalrepo
 	fi
diff --git a/env.tmpl b/env.tmpl
index 8c98a4bd4de3c418a207571ea2e9af44ce762fd4..38363f6ac060f18ed6a968ec8d8d9d215af50279 100755
--- a/env.tmpl
+++ b/env.tmpl
@@ -5,6 +5,8 @@
 # Your main git tree where you keep your in-progress work.
 # This will be named 'main'.
 myrepo=git://linuxtv.org/hverkuil/media_tree.git
+# You can also specify a specific branch to checkout
+#mybranch=example_branch
 
 # Optional: your local git tree where you do your development
 # This will be named 'local', so to build a branch from your