diff --git a/release-notes/8.0.0/feat/4262.md b/release-notes/8.0.0/feat/4262.md
new file mode 100644
index 0000000000..9918f065bb
--- /dev/null
+++ b/release-notes/8.0.0/feat/4262.md
@@ -0,0 +1 @@
+Introduced branch/tag dropdown in code search page if using git-grep.
diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl
index 3f5b22b0ce..6d114c81e4 100644
--- a/templates/repo/search.tmpl
+++ b/templates/repo/search.tmpl
@@ -2,6 +2,12 @@
{{template "repo/header" .}}
+ {{if $.CodeIndexerDisabled}}
+ {{$branchURLPrefix := printf "%s/search/branch/" $.RepoLink}}
+ {{$tagURLPrefix := printf "%s/search/tag/" $.RepoLink}}
+ {{$suffix := printf "?q=%s&fuzzy=%t" (.Keyword|QueryEscape) .IsFuzzy}}
+ {{template "repo/branch_dropdown" dict "root" . "ContainerClasses" "tw-mb-3" "branchURLPrefix" $branchURLPrefix "branchURLSuffix" $suffix "tagURLPrefix" $tagURLPrefix "tagURLSuffix" $suffix}}
+ {{end}}
{{template "shared/search/code/search" .}}
diff --git a/tests/integration/repo_search_test.go b/tests/integration/repo_search_test.go
index f177c94b87..13fe8cebb5 100644
--- a/tests/integration/repo_search_test.go
+++ b/tests/integration/repo_search_test.go
@@ -94,8 +94,13 @@ func testSearch(t *testing.T, url string, expected []string, indexer bool) {
resp := MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
- msg := doc.Find(".repository").Find(".ui.container").Find(".ui.message[data-test-tag=grep]")
- assert.EqualValues(t, indexer, len(msg.Nodes) == 0)
+ container := doc.Find(".repository").Find(".ui.container")
+
+ grepMsg := container.Find(".ui.message[data-test-tag=grep]")
+ assert.EqualValues(t, indexer, len(grepMsg.Nodes) == 0)
+
+ branchDropdown := container.Find(".js-branch-tag-selector")
+ assert.EqualValues(t, indexer, len(branchDropdown.Nodes) == 0)
filenames := resultFilenames(t, doc)
assert.EqualValues(t, expected, filenames)