diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 27a0d05144..5fb573a381 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -52,6 +52,11 @@ Supported SRC_URI options are:
    For local git:// urls to use the current branch HEAD as the
revision for use with
    AUTOREV. Implies nobranch.

+- lfs
+    Enable the checkout to use LFS for large files. This will
download all LFS files
+    in the download step, as the unpack step does not have network access.
+    The default is "1", set lfs=0 to skip.
+
 """

 # Copyright (C) 2005 Richard Purdie
@@ -629,6 +634,8 @@ class Git(FetchMethod):
                 raise bb.fetch2.FetchError("Repository %s has LFS
content, install git-lfs on host to download (or set lfs=0 to ignore
it)" % (repourl))
             elif not need_lfs:
                 bb.note("Repository %s has LFS content but it is not
being fetched" % (repourl))
+            else:
+                runfetchcmd("%s lfs install" % ud.basecmd, d, workdir=destdir)

         if not ud.nocheckout:
             if subpath:
@@ -688,8 +695,11 @@ class Git(FetchMethod):
         Check if the repository has 'lfs' (large file) content
         """

-        # The bare clonedir doesn't use the remote names; it has the
branch immediately.
-        if wd == ud.clonedir:
+        if ud.nobranch:
+            # If no branch is specified, use the current git commit
+            refname = self._build_revision(ud, d, ud.names[0])
+        elif wd == ud.clonedir:
+            # The bare clonedir doesn't use the remote names; it has
the branch immediately.
             refname = ud.branches[ud.names[0]]
         else:
             refname = "origin/%s" % ud.branches[ud.names[0]]
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index 0e806c0ff7..c7a23407c1 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -2277,7 +2277,7 @@ class GitLfsTest(FetcherTest):

     @skipIfNoGitLFS()
     @skipIfNoNetwork()
-    def test_real_git_lfs_repo_succeeds(self):
+    def test_real_git_lfs_repo_skips(self):
         self.d.setVar('SRC_URI',
"git://gitlab.com/gitlab-examples/lfs.git;protocol=https;branch=master;lfs=0")
         f = self.get_real_git_lfs_file()
