diff --git a/Gemfile b/Gemfile
index b827b59adf987c5f818ef440bb35ab6516577da2..708211e3f40c3cd2910005b83325928b4d94645c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -23,7 +23,7 @@ gem 'omniauth-github'
 
 # Extracting information from a git repository
 # Provide access to Gitlab::Git library
-gem "gitlab_git", '2.3.1'
+gem "gitlab_git", "~> 3.0.0.beta1"
 
 # Ruby/Rack Git Smart-HTTP Server Handler
 gem 'gitlab-grack', '~> 1.0.1', require: 'grack'
diff --git a/Gemfile.lock b/Gemfile.lock
index 7327e5c28151f1883877b0b0875b0227c080cec7..c66036295aab74f75b7febc858839a47538e2e04 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -174,7 +174,7 @@ GEM
     gitlab-pygments.rb (0.3.2)
       posix-spawn (~> 0.3.6)
       yajl-ruby (~> 1.1.0)
-    gitlab_git (2.3.1)
+    gitlab_git (3.0.0.beta1)
       activesupport (~> 3.2.13)
       github-linguist (~> 2.3.4)
       gitlab-grit (~> 2.6.0)
@@ -574,7 +574,7 @@ DEPENDENCIES
   gitlab-gollum-lib (~> 1.0.1)
   gitlab-grack (~> 1.0.1)
   gitlab-pygments.rb (~> 0.3.2)
-  gitlab_git (= 2.3.1)
+  gitlab_git (~> 3.0.0.beta1)
   gitlab_meta (= 6.0)
   gitlab_omniauth-ldap (= 1.0.3)
   gon
diff --git a/app/assets/stylesheets/gitlab_bootstrap/files.scss b/app/assets/stylesheets/gitlab_bootstrap/files.scss
index 8ba8c93e3d6affb0412c67ca0a4201cfb9d115e8..a286e530cd6025a1b958c7c24ba98d0cd887c52a 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/files.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/files.scss
@@ -69,6 +69,12 @@
 
     }
 
+    &.blob-no-preview {
+      background: #eee;
+      text-shadow: 0 1px 2px #FFF;
+      padding: 100px 0;
+    }
+
     /**
      *  Blame file
      */
diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb
index e58b450720212df28c4726230d7c461d26bfa45b..f22c6497cbf218544869d587abf3c9c75219440c 100644
--- a/app/controllers/projects/blame_controller.rb
+++ b/app/controllers/projects/blame_controller.rb
@@ -8,7 +8,7 @@ class Projects::BlameController < Projects::ApplicationController
   before_filter :require_non_empty_project
 
   def show
-    @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
+    @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path)
     @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path)
   end
 end
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index b1329c01ce77c83144df87b4dc6bd7546dc67540..878f25c7c03da2532bb960722ba9c8b777fdb9b6 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -8,6 +8,8 @@ class Projects::BlobController < Projects::ApplicationController
   before_filter :require_non_empty_project
 
   def show
-    @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
+    @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path)
+
+    not_found! unless @blob
   end
 end
diff --git a/app/controllers/projects/edit_tree_controller.rb b/app/controllers/projects/edit_tree_controller.rb
index 3b945fc7126c29deff2b5a3f3b0bb8abf9c3520c..edea80a5ccc9668f2f232b36013fe2964a9f30fc 100644
--- a/app/controllers/projects/edit_tree_controller.rb
+++ b/app/controllers/projects/edit_tree_controller.rb
@@ -32,9 +32,9 @@ def update
   private
 
   def edit_requirements
-    @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
+    @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path)
 
-    unless @blob.exists? && @blob.text?
+    unless @blob
       redirect_to project_blob_path(@project, @id), notice: "You can only edit text files"
     end
 
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb
index 0c23d411f4c5040bbec86bb4ef73bcce69344e7d..8633b225b64d4fb251e78a3d67e3ad9b4d4b9732 100644
--- a/app/controllers/projects/raw_controller.rb
+++ b/app/controllers/projects/raw_controller.rb
@@ -8,9 +8,9 @@ class Projects::RawController < Projects::ApplicationController
   before_filter :require_non_empty_project
 
   def show
-    @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
+    @blob = Gitlab::Git::Blob.find(@repository, @commit.id, @path)
 
-    if @blob.exists?
+    if @blob
       type = if @blob.mime_type =~ /html|javascript/
                'text/plain; charset=utf-8'
              else
diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb
index e5c090e1f4dab63e565723a5d107d78d4518865d..16621c0371e1b7e6eaae25f05a1f136614133a84 100644
--- a/app/controllers/projects/refs_controller.rb
+++ b/app/controllers/projects/refs_controller.rb
@@ -24,13 +24,14 @@ def switch
       format.js do
         @ref = params[:ref]
         define_tree_vars
+        tree
         render "tree"
       end
     end
   end
 
   def logs_tree
-    contents = @tree.entries
+    contents = tree.entries
     @logs = contents.map do |content|
       file = params[:path] ? File.join(params[:path], content.name) : content.name
       last_commit = @repo.commits(@commit.id, file, 1).last
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index 5d543f356658059e39421267adad8a4dc69bc1de..1150efbea9d947b47e70046049a5bfbeb8bf1646 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -8,6 +8,8 @@ class Projects::TreeController < Projects::ApplicationController
   before_filter :require_non_empty_project
 
   def show
+    return not_found! if tree.entries.empty?
+
     respond_to do |format|
       format.html
       # Disable cache so browser history works
diff --git a/app/helpers/blobs_helper.rb b/app/helpers/blobs_helper.rb
new file mode 100644
index 0000000000000000000000000000000000000000..26605d810266f4b16e861c26869aad00026c8b44
--- /dev/null
+++ b/app/helpers/blobs_helper.rb
@@ -0,0 +1,5 @@
+module BlobsHelper
+  def find_blob(repository, sha, path)
+    Gitlab::Git::Blob.find(repository, sha, path)
+  end
+end
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 73d36d0801c75b14b83a4885bd0249b6e80141d5..2dbc1cffb16c7ecfe7120d8333408ff9cde2b706 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -67,9 +67,9 @@ def allowed_tree_edit?
   end
 
   def tree_breadcrumbs(tree, max_links = 2)
-    if tree.path
+    if @path.present?
       part_path = ""
-      parts = tree.path.split("\/")
+      parts = @path.split("\/")
 
       yield('..', nil) if parts.count > max_links
 
@@ -78,14 +78,14 @@ def tree_breadcrumbs(tree, max_links = 2)
         part_path = part if part_path.empty?
 
         next unless parts.last(2).include?(part) if parts.count > max_links
-        yield(part, tree_join(tree.ref, part_path))
+        yield(part, tree_join(@ref, part_path))
       end
     end
   end
 
   def up_dir_path tree
-    file = File.join(tree.path, "..")
-    tree_join(tree.ref, file)
+    file = File.join(@path, "..")
+    tree_join(@ref, file)
   end
 
   def leave_edit_message
diff --git a/app/models/repository.rb b/app/models/repository.rb
index aeec48ee5cc82e40c249494621ae6bb1aeb9298b..145bd51ffd378f00a17e83031407882e3098f522 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1,14 +1,19 @@
 class Repository
   include Gitlab::ShellAdapter
 
-  attr_accessor :raw_repository
+  attr_accessor :raw_repository, :path_with_namespace
 
   def initialize(path_with_namespace, default_branch)
-    @raw_repository = Gitlab::Git::Repository.new(path_with_namespace, default_branch)
+    @path_with_namespace = path_with_namespace
+    @raw_repository = Gitlab::Git::Repository.new(path_to_repo) if path_with_namespace
   rescue Gitlab::Git::Repository::NoRepository
     nil
   end
 
+  def path_to_repo
+    @path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, path_with_namespace + ".git")
+  end
+
   def exists?
     raw_repository
   end
diff --git a/app/models/tree.rb b/app/models/tree.rb
index 042050527c1df0979055cf3fa9804330005a1506..5fbad19b468a11bab4fd78b5e6c5eb1c0a71527f 100644
--- a/app/models/tree.rb
+++ b/app/models/tree.rb
@@ -1,17 +1,25 @@
 class Tree
-  attr_accessor :raw
+  attr_accessor :entries, :readme
 
-  def initialize(repository, sha, ref = nil, path = nil)
-    @raw = Gitlab::Git::Tree.new(repository, sha, ref, path)
+  def initialize(repository, sha, path = '/')
+    path = '/' if path.blank?
+    git_repo = repository.raw_repository
+    @entries = Gitlab::Git::Tree.where(git_repo, sha, path)
+
+    if readme_tree = @entries.find(&:readme?)
+      @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_tree.name)
+    end
   end
 
-  def method_missing(m, *args, &block)
-    @raw.send(m, *args, &block)
+  def trees
+    @entries.select(&:dir?)
   end
 
-  def respond_to?(method)
-    return true if @raw.respond_to?(method)
+  def blobs
+    @entries.select(&:file?)
+  end
 
-    super
+  def submodules
+    @entries.select(&:submodule?)
   end
 end
diff --git a/app/views/projects/blob/_download.html.haml b/app/views/projects/blob/_download.html.haml
index f3da1a2a2196609e2f0f9f406b50f89b83259334..ff317f9020967e356bb81d4e773d411220b2c3ef 100644
--- a/app/views/projects/blob/_download.html.haml
+++ b/app/views/projects/blob/_download.html.haml
@@ -1,8 +1,7 @@
-.file-content.blob_file
+.file-content.blob_file.blob-no-preview
   %center
     = link_to project_raw_path(@project, @id) do
-      %div.padded
-        %h4
-          %i.icon-download-alt
-          %br
-          Download (#{number_to_human_size blob.size})
+      %h1.light
+        %i.icon-download-alt
+      %h4
+        Download (#{number_to_human_size blob.size})
diff --git a/app/views/projects/commits/_diffs.html.haml b/app/views/projects/commits/_diffs.html.haml
index c51f1b6eff50504cb5acd897eb3caa12e6628ebe..f60c4661100ab8c4d5ad8121ab75f371fabe5c64 100644
--- a/app/views/projects/commits/_diffs.html.haml
+++ b/app/views/projects/commits/_diffs.html.haml
@@ -37,9 +37,9 @@
   - unless @suppress_diff
     - diffs.each_with_index do |diff, i|
       - next if diff.diff.empty?
-      - file = Gitlab::Git::Blob.new(project.repository, @commit.id, @ref, diff.new_path)
-      - file = Gitlab::Git::Blob.new(project.repository, @commit.parent_id, @ref, diff.old_path) unless file.exists?
-      - next unless file.exists?
+      - file = find_blob(project.repository, @commit.id, diff.new_path)
+      - file = find_blob(project.repository, @commit.parent_id, diff.old_path) unless file
+      - next unless file
       .file{id: "diff-#{i}"}
         .header
           - if diff.deleted_file
@@ -64,7 +64,7 @@
           - if file.text?
             = render "projects/commits/text_file", diff: diff, index: i
           - elsif file.image?
-            - old_file = Gitlab::Git::Blob.new(project.repository, @commit.parent_id, @ref, diff.old_path) if @commit.parent_id
+            - old_file = find_blob(project.repository, @commit.parent_id, diff.old_path) if @commit.parent_id
             = render "projects/commits/image", diff: diff, old_file: old_file, file: file, index: i
           - else
             %p.nothing_here_message No preview for this file type
diff --git a/app/views/projects/tree/_tree.html.haml b/app/views/projects/tree/_tree.html.haml
index ae5f30c00048616dead7c05049bbf4e71b7904c3..eadfd33bd3cb21dc7d6ec719aab0ed8df3c007a3 100644
--- a/app/views/projects/tree/_tree.html.haml
+++ b/app/views/projects/tree/_tree.html.haml
@@ -28,7 +28,7 @@
             = truncate(@commit.title, length: 50)
         %th= link_to "history", project_commits_path(@project, @id), class: "pull-right"
 
-    - if tree.up_dir?
+    - if @path.present?
       %tr.tree-item
         %td.tree-item-file-name
           = image_tag "file_empty.png", size: '16x16'
diff --git a/config/initializers/5_backend.rb b/config/initializers/5_backend.rb
index e60d9559c9462852abd8f1ae9a7c0b6426fff7a2..7c2e7f3900053c1b1b9b893faa0f1dc9c2c244ba 100644
--- a/config/initializers/5_backend.rb
+++ b/config/initializers/5_backend.rb
@@ -6,6 +6,3 @@
 
 # GitLab shell adapter
 require Rails.root.join("lib", "gitlab", "backend", "shell_adapter")
-
-# Gitlab Git repos path
-Gitlab::Git::Repository.repos_path = Gitlab.config.gitlab_shell.repos_path
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index c2b229b0172525a7cd78cb1170e542c02c359e73..1a911eae2bb13c8cbcb082d216498cadb6337f8e 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -139,7 +139,7 @@ def handle_project_member_errors(errors)
         path = params[:path] || nil
 
         commit = user_project.repository.commit(ref)
-        tree = Tree.new(user_project.repository, commit.id, ref, path)
+        tree = Tree.new(user_project.repository, commit.id, path)
 
         trees = []
 
@@ -168,8 +168,8 @@ def handle_project_member_errors(errors)
         commit = repo.commit(ref)
         not_found! "Commit" unless commit
 
-        blob = Gitlab::Git::Blob.new(repo, commit.id, ref, params[:filepath])
-        not_found! "File" unless blob.exists?
+        blob = Gitlab::Git::Blob.find(repo, commit.id, params[:filepath])
+        not_found! "File" unless blob
 
         env['api.format'] = :txt
 
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index 53bc079296aedb6faed3732742053601ac730795..6e7872dcd033655dfe70ab1cb0f9a309f8ca3d3e 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -86,7 +86,6 @@ def extract_ref(id)
   # - @ref    - A string representing the ref (e.g., the branch, tag, or commit SHA)
   # - @path   - A string representing the filesystem path
   # - @commit - A Commit representing the commit from the given ref
-  # - @tree   - A Tree representing the tree at the given ref/path
   #
   # If the :id parameter appears to be requesting a specific response format,
   # that will be handled as well.
@@ -107,15 +106,20 @@ def assign_ref_vars
     else
       @commit = @repo.commit(@options[:extended_sha1])
     end
-    @tree = Tree.new(@repo, @commit.id, @ref, @path)
+
+    raise InvalidPathError unless @commit
+
     @hex_path = Digest::SHA1.hexdigest(@path)
     @logs_path = logs_file_project_ref_path(@project, @ref, @path)
 
-    raise InvalidPathError unless @tree.exists?
   rescue RuntimeError, NoMethodError, InvalidPathError
     not_found!
   end
 
+  def tree
+    @tree ||= Tree.new(@repo, @commit.id, @path)
+  end
+
   private
 
   def get_id