diff --git a/app/views/graph/_head.html.haml b/app/views/graph/_head.html.haml
index e6be40aec9c..7a5b3c6f43d 100644
--- a/app/views/graph/_head.html.haml
+++ b/app/views/graph/_head.html.haml
@@ -4,6 +4,14 @@
.clearfix
.pull-left
= render partial: 'shared/ref_switcher', locals: {destination: 'graph'}
+ .pull-left
+ = form_tag project_graph_path(@project, @id), method: :get do |f|
+ .control-group
+ = label_tag :filter_ref, "Show only selected ref", class: 'control-label light'
+ .controls
+ = check_box_tag :filter_ref, 1, @options[:filter_ref]
+ - @options.each do |key, value|
+ = hidden_field_tag(key, value, id: nil) unless key == "filter_ref"
.search.pull-right
= form_tag project_graph_path(@project, @id), method: :get do |f|
diff --git a/app/views/graph/show.html.haml b/app/views/graph/show.html.haml
index f361b8b2ea8..0ee6648317c 100644
--- a/app/views/graph/show.html.haml
+++ b/app/views/graph/show.html.haml
@@ -7,6 +7,9 @@
:javascript
var branch_graph;
+ $("#filter_ref").click(function() {
+ $(this).closest('form').submit();
+ });
branch_graph = new BranchGraph($("#holder"), {
url: '#{project_graph_path(@project, @ref, @options.merge(format: :json))}',
commit_url: '#{project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")}',