diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py
index 020980d7c..f242fb0ad 100644
--- a/conans/client/cmd/export.py
+++ b/conans/client/cmd/export.py
@@ -60,7 +60,7 @@ def cmd_export(conanfile_path, conanfile, reference, keep_source, output, client
                           keep_source)
 
 
-def _capture_export_scm_data(conanfile, src_path, destination_folder, output, paths, conan_ref):
+def _capture_export_scm_data(conanfile, conanfile_dir, destination_folder, output, paths, conan_ref):
 
     scm_src_file = paths.scm_folder(conan_ref)
     if os.path.exists(scm_src_file):
@@ -71,7 +71,7 @@ def _capture_export_scm_data(conanfile, src_path, destination_folder, output, pa
     if not scm_data or not (scm_data.capture_origin or scm_data.capture_revision):
         return
 
-    scm = SCM(scm_data, src_path)
+    scm = SCM(scm_data, conanfile_dir)
 
     if scm_data.url == "auto":
         origin = scm.get_remote_url()
@@ -87,6 +87,7 @@ def _capture_export_scm_data(conanfile, src_path, destination_folder, output, pa
         output.success("Revision deduced by 'auto': %s" % scm_data.revision)
 
     # Generate the scm_folder.txt file pointing to the src_path
+    src_path = scm.get_repo_root()
     save(scm_src_file, src_path.replace("\\", "/"))
     scm_data.replace_in_file(os.path.join(destination_folder, "conanfile.py"))
 
diff --git a/conans/client/tools/scm.py b/conans/client/tools/scm.py
index 0c1c84c2d..50b06b46d 100644
--- a/conans/client/tools/scm.py
+++ b/conans/client/tools/scm.py
@@ -13,8 +13,8 @@ from conans.util.files import decode_text, to_file_bytes
 
 class Git(object):
 
-    def __init__(self, folder=None, verify_ssl=True, username=None, password=None, force_english=True,
-                 runner=None):
+    def __init__(self, folder=None, verify_ssl=True, username=None, password=None,
+                 force_english=True, runner=None):
         self.folder = folder or os.getcwd()
         if not os.path.exists(self.folder):
             os.makedirs(self.folder)
@@ -33,6 +33,9 @@ class Git(object):
                 else:
                     return self._runner(command)
 
+    def get_repo_root(self):
+        return self.run("rev-parse --show-toplevel")
+
     def get_url_with_credentials(self, url):
         if not self._username or not self._password:
             return url
diff --git a/conans/model/scm.py b/conans/model/scm.py
index e7ff64aca..84210fc25 100644
--- a/conans/model/scm.py
+++ b/conans/model/scm.py
@@ -75,3 +75,6 @@ class SCM(object):
 
     def get_revision(self):
         return self.repo.get_revision()
+
+    def get_repo_root(self):
+        return self.repo.get_repo_root()

[SCM] SCM feature + recipe in a repo subfolder leads to "same computer clone" bug
Getting back to our Conan recipe, conan `1.7.1` solves the problem described #3322 thus (re)allowing a recipe living in subfolder of the repository to use the `scm` feature.
Sadly, another bug, initially described in #3069 (under the name _same computer optimization problem_) is still present: when `conan create`ing the recipe, in this situation, the creation fails, complaining there are no files in the `build` folder (and indeed, there are none).

It seems the analysis made in #3069 is still relevant:
Basically, when calling `conan create`, an optimization described in the [tip box of this documentation section](https://docs.conan.io/en/latest/creating_packages/package_repo.html#capturing-the-remote-and-commit-from-git-scm-experimental) creates an `scm_folder.txt` file in the conan package. When this file is present, conan tries to clone the repo from the path in this file instead of the git url stored in the exported recipe. 

Sadly, this file contains the path to the folder containing the recipe, instead of the path to the root of the repository. So, when the recipe is at the root of the repository, the behaviour appears correct. But if the recipe is stored in a subfolder, then it seems nothing is cloned over to the build folder, failing the process.
diff --git a/conans/test/functional/scm_test.py b/conans/test/functional/scm_test.py
index 24a7ea320..1e19a06f4 100644
--- a/conans/test/functional/scm_test.py
+++ b/conans/test/functional/scm_test.py
@@ -149,6 +149,21 @@ class ConanLib(ConanFile):
         self.assertTrue(os.path.exists(os.path.join(folder, "mysub", "myfile.txt")))
         self.assertFalse(os.path.exists(os.path.join(folder, "mysub", "conanfile.py")))
 
+    def test_auto_conanfile_no_root(self):
+        """
+        Conanfile is not in the root of the repo: https://github.com/conan-io/conan/issues/3465
+        """
+        curdir = self.client.current_folder
+        conanfile = base.format(url="auto", revision="auto")
+        self.client.save({"conan/conanfile.py": conanfile, "myfile.txt": "content of my file"})
+        self._commit_contents()
+        self.client.runner('git remote add origin https://myrepo.com.git', cwd=curdir)
+
+        # Create the package
+        self.client.run("create conan/ user/channel")
+        sources_dir = self.client.client_cache.scm_folder(self.reference)
+        self.assertEquals(load(sources_dir), curdir.replace('\\', '/'))  # Root of git is 'curdir'
+
     def test_deleted_source_folder(self):
         path, commit = create_local_git_repo({"myfile": "contents"}, branch="my_release")
         curdir = self.client.current_folder.replace("\\", "/")
diff --git a/conans/test/util/tools_test.py b/conans/test/util/tools_test.py
index d60c3365c..d3db53ab2 100644
--- a/conans/test/util/tools_test.py
+++ b/conans/test/util/tools_test.py
@@ -1100,6 +1100,19 @@ ProgramFiles(x86)=C:\Program Files (x86)
 
 class GitToolTest(unittest.TestCase):
 
+    def test_repo_root(self):
+        root_path, _ = create_local_git_repo({"myfile": "anything"})
+
+        # Initialized in the root folder
+        git = Git(root_path)
+        self.assertEqual(root_path, git.get_repo_root())
+
+        # Initialized elsewhere
+        subfolder = os.path.join(root_path, 'subfolder')
+        os.makedirs(subfolder)
+        git = Git(subfolder)
+        self.assertEqual(root_path, git.get_repo_root())
+
     def test_clone_git(self):
         path, _ = create_local_git_repo({"myfile": "contents"})
         tmp = temp_folder()

pip install -e .[dev]
parse_log_pytest
requirements.txt
nose pytest
apt-get update apt-get install -y gcc cmake
3.6
conans/requirements.txt conans/requirements_server.txt conans/requirements_dev.txt conans/requirements_osx.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
asn1crypto==1.5.1
astroid==2.11.7
attrs==22.2.0
beautifulsoup4==4.12.3
bottle==0.12.25
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
codecov==2.1.13
colorama==0.3.9
-e git+https://github.com/conan-io/conan.git@82631b05304f07dddfbd9f2cb0721e10fcd43d17#egg=conan
coverage==4.2
cryptography==2.3.1
deprecation==2.0.7
dill==0.3.4
distro==1.1.0
fasteners==0.19
future==0.16.0
idna==2.6
importlib-metadata==4.8.3
iniconfig==1.1.1
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.7.0
mock==1.3.0
ndg-httpsclient==0.4.4
node-semver==0.2.0
nose==1.3.7
packaging==21.3
parameterized==0.8.1
patch==1.16
pbr==6.1.1
platformdirs==2.4.0
pluggy==1.0.0
pluginbase==0.7
py==1.11.0
pyasn==1.5.0b7
pyasn1==0.5.1
pycparser==2.21
Pygments==2.14.0
PyJWT==1.7.1
pylint==2.13.9
pyOpenSSL==17.5.0
pyparsing==3.1.4
pytest==7.0.1
PyYAML==3.13
requests==2.27.1
six==1.17.0
soupsieve==2.3.2.post1
tomli==1.2.3
typed-ast==1.5.5
typing_extensions==4.1.1
urllib3==1.26.20
waitress==2.0.0
WebOb==1.8.9
WebTest==2.0.35
wrapt==1.16.0
zipp==3.6.0

name: conan
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - asn1crypto==1.5.1
      - astroid==2.11.7
      - attrs==22.2.0
      - beautifulsoup4==4.12.3
      - bottle==0.12.25
      - cffi==1.15.1
      - charset-normalizer==2.0.12
      - codecov==2.1.13
      - colorama==0.3.9
      - coverage==4.2
      - cryptography==2.3.1
      - deprecation==2.0.7
      - dill==0.3.4
      - distro==1.1.0
      - fasteners==0.19
      - future==0.16.0
      - idna==2.6
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - isort==5.10.1
      - lazy-object-proxy==1.7.1
      - mccabe==0.7.0
      - mock==1.3.0
      - ndg-httpsclient==0.4.4
      - node-semver==0.2.0
      - nose==1.3.7
      - packaging==21.3
      - parameterized==0.8.1
      - patch==1.16
      - pbr==6.1.1
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pluginbase==0.7
      - py==1.11.0
      - pyasn==1.5.0b7
      - pyasn1==0.5.1
      - pycparser==2.21
      - pygments==2.14.0
      - pyjwt==1.7.1
      - pylint==2.13.9
      - pyopenssl==17.5.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pyyaml==3.13
      - requests==2.27.1
      - six==1.17.0
      - soupsieve==2.3.2.post1
      - tomli==1.2.3
      - typed-ast==1.5.5
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - waitress==2.0.0
      - webob==1.8.9
      - webtest==2.0.35
      - wrapt==1.16.0
      - zipp==3.6.0
prefix: /opt/conda/envs/conan

conans/test/util/tools_test.py::GitToolTest::test_repo_root
conans/test/functional/scm_test.py::SCMTest::test_auto_conanfile_no_root conans/test/functional/scm_test.py::SCMTest::test_auto_filesystem_remote_git conans/test/functional/scm_test.py::SCMTest::test_auto_git conans/test/functional/scm_test.py::SCMTest::test_auto_subfolder conans/test/functional/scm_test.py::SCMTest::test_deleted_source_folder conans/test/functional/scm_test.py::SCMTest::test_excluded_repo_files conans/test/functional/scm_test.py::SCMTest::test_install_checked_out conans/test/functional/scm_test.py::SCMTest::test_local_source conans/test/functional/scm_test.py::SCMTest::test_local_source_subfolder conans/test/functional/scm_test.py::SCMTest::test_repeat_clone_changing_subfolder conans/test/functional/scm_test.py::SCMTest::test_source_method_export_sources_and_scm_mixed conans/test/functional/scm_test.py::SCMTest::test_source_removed_in_local_cache conans/test/functional/scm_test.py::SCMTest::test_submodule conans/test/util/tools_test.py::ToolsTest::test_get_env_in_conanfile conans/test/util/tools_test.py::ToolsTest::test_global_tools_overrided conans/test/util/tools_test.py::GitToolTest::test_clone_submodule_git
conans/test/functional/scm_test.py::SCMTest::test_scm_other_type_ignored conans/test/util/tools_test.py::ReplaceInFileTest::test_replace_in_file conans/test/util/tools_test.py::ToolsTest::test_environment_nested conans/test/util/tools_test.py::GitToolTest::test_clone_existing_folder_git conans/test/util/tools_test.py::GitToolTest::test_clone_existing_folder_without_branch conans/test/util/tools_test.py::GitToolTest::test_clone_git conans/test/util/tools_test.py::GitToolTest::test_credentials conans/test/util/tools_test.py::GitToolTest::test_verify_ssl
conans/client/tools/scm.py conans/client/cmd/export.py conans/model/scm.py
conans/client/tools/scm.py conans/client/cmd/export.py conans/model/scm.py