diff --git a/dvc/command/version.py b/dvc/command/version.py
index d964eaa8b..770d9ad3c 100644
--- a/dvc/command/version.py
+++ b/dvc/command/version.py
@@ -42,22 +42,22 @@ class CmdVersion(CmdBaseNoRepo):
             binary=binary,
         )
 
-        if psutil:
-            try:
-                repo = Repo()
-                root_directory = repo.root_dir
+        try:
+            repo = Repo()
+            root_directory = repo.root_dir
+
+            info += "Cache: {cache}\n".format(
+                cache=self.get_linktype_support_info(repo)
+            )
 
+            if psutil:
                 info += (
-                    "Cache: {cache}\n"
                     "Filesystem type (cache directory): {fs_cache}\n"
-                ).format(
-                    cache=self.get_linktype_support_info(repo),
-                    fs_cache=self.get_fs_type(repo.cache.local.cache_dir),
-                )
-
-            except NotDvcRepoError:
-                root_directory = os.getcwd()
+                ).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir))
+        except NotDvcRepoError:
+            root_directory = os.getcwd()
 
+        if psutil:
             info += ("Filesystem type (workspace): {fs_root}").format(
                 fs_root=self.get_fs_type(os.path.abspath(root_directory))
             )
diff --git a/dvc/scm/git/__init__.py b/dvc/scm/git/__init__.py
index c0592e896..883c75afd 100644
--- a/dvc/scm/git/__init__.py
+++ b/dvc/scm/git/__init__.py
@@ -216,19 +216,17 @@ class Git(Base):
         return [t.name for t in self.git.tags]
 
     def _install_hook(self, name, cmd):
-        command = "dvc {}".format(cmd)
+        command = '[ -z "$(git ls-files .dvc)" ] || exec dvc {}'.format(cmd)
 
         hook = os.path.join(self.root_dir, self.GIT_DIR, "hooks", name)
 
         if os.path.isfile(hook):
             with open(hook, "r+") as fobj:
                 if command not in fobj.read():
-                    fobj.write("exec {command}\n".format(command=command))
+                    fobj.write("{command}\n".format(command=command))
         else:
             with open(hook, "w+") as fobj:
-                fobj.write(
-                    "#!/bin/sh\n" "exec {command}\n".format(command=command)
-                )
+                fobj.write("#!/bin/sh\n" "{command}\n".format(command=command))
 
         os.chmod(hook, 0o777)
 

post-checkout hook breaks checkout and rebase when adopting DVC in a branch
When adopting DVC in an existing repository with PR code-review workflow, it will be landing in a branch that isn't master. This branch then has problematic interactions where work continues on master before the dvc adoption lands there.

Specifically, once you've done `dvc init`, committed that, and then `dvc install`, the post-checkout hook breaks `git checkout` and `git rebase` between the master branch and the adopting-dvc branch.

To reproduce:

```bash
mkdir dvc-test
cd dvc-test
git init
echo "Testing" > README.md
git add README.md
git commit -m "Initial commit"
git checkout -b start-using-dvc
dvc init
git commit -m "dvc init"
dvc install
```

I go on experimenting with dvc, but then I have to pause the dvc adoption to do some work on the master branch.:

```bash
git stash save "experimenting with dvc"
git checkout master
```

This last command succeeds but outputs:

```
Switched to branch 'master'
Adding '.dvc/state' to '.dvc/.gitignore'.
Adding '.dvc/lock' to '.dvc/.gitignore'.
Adding '.dvc/config.local' to '.dvc/.gitignore'.
Adding '.dvc/updater' to '.dvc/.gitignore'.
Adding '.dvc/updater.lock' to '.dvc/.gitignore'.
Adding '.dvc/repos' to '.dvc/.gitignore'.
Adding '.dvc/state-journal' to '.dvc/.gitignore'.
Adding '.dvc/state-wal' to '.dvc/.gitignore'.
Adding '.dvc/cache' to '.dvc/.gitignore'.
```

... uh-oh. I'm on master where dvc hasn't been taken into use, so I (or my tooling) shouldn't be putting anything in `.dvc`.

I continue with the master work and then return to DVC:

```bash
echo "Progress" > README.md
git commit README.md -m "Progress"
git checkout start-using-dvc
```

That last command fails with:

```
error: The following untracked working tree files would be overwritten by checkout:
	.dvc/.gitignore
Please move or remove them before you switch branches.
Aborting
```

... which is not normal in git; with a clean working tree, `git checkout` to switch branches should always work.

I workaround this and want to keep going, rebasing my dvc experiment branch on current tip of master:

```bash
rm .dvc/.gitignore
git checkout start-using-dvc
git rebase master
```

That rebase fails with:

```
First, rewinding head to replay your work on top of it...
Adding '.dvc/state' to '.dvc/.gitignore'.
Adding '.dvc/lock' to '.dvc/.gitignore'.
Adding '.dvc/config.local' to '.dvc/.gitignore'.
Adding '.dvc/updater' to '.dvc/.gitignore'.
Adding '.dvc/updater.lock' to '.dvc/.gitignore'.
Adding '.dvc/repos' to '.dvc/.gitignore'.
Adding '.dvc/state-journal' to '.dvc/.gitignore'.
Adding '.dvc/state-wal' to '.dvc/.gitignore'.
Adding '.dvc/cache' to '.dvc/.gitignore'.
Applying: dvc init
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: The following untracked working tree files would be overwritten by merge:
	.dvc/.gitignore
Please move or remove them before you merge.
Aborting
error: Failed to merge in the changes.
Patch failed at 0001 dvc init
hint: Use 'git am --show-current-patch' to see the failed patch
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
```

Deleting the post-checkout hook makes the rebase work just fine:

```bash
rm .git/hooks/post-checkout
git rebase master
```

So probably the post-checkout hook should abort with an informative message if you're on a branch where dvc _hasn't_ been adopted. Not sure whether that check is as simple as checking existence of `.dvc` or whether that breaks other legitimate uses of the hook.

My `dvc --version` is 0.50.1, installed with homebrew (`brew cask`).
diff --git a/tests/func/test_install.py b/tests/func/test_install.py
index 5e5efee29..1e3c7b8ba 100644
--- a/tests/func/test_install.py
+++ b/tests/func/test_install.py
@@ -36,7 +36,11 @@ class TestInstall(object):
 
         assert main(["install"]) == 0
 
-        expected_script = "#!/bin/sh\n" "echo hello\n" "exec dvc checkout\n"
+        expected_script = (
+            "#!/bin/sh\n"
+            "echo hello\n"
+            '[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
+        )
 
         with open(self._hook("post-checkout"), "r") as fobj:
             assert fobj.read() == expected_script
@@ -45,7 +49,10 @@ class TestInstall(object):
         assert main(["install"]) == 0
         assert main(["install"]) == 0
 
-        expected_script = "#!/bin/sh\n" "exec dvc checkout\n"
+        expected_script = (
+            "#!/bin/sh\n"
+            '[ -z "$(git ls-files .dvc)" ] || exec dvc checkout\n'
+        )
 
         with open(self._hook("post-checkout"), "r") as fobj:
             assert fobj.read() == expected_script
diff --git a/tests/func/test_version.py b/tests/func/test_version.py
index a040c1e14..d0fe6f2eb 100644
--- a/tests/func/test_version.py
+++ b/tests/func/test_version.py
@@ -1,6 +1,8 @@
 import re
+import pytest
 
 from dvc.main import main
+from dvc.command.version import psutil
 
 
 def test_info_in_repo(dvc_repo, caplog):
@@ -11,13 +13,19 @@ def test_info_in_repo(dvc_repo, caplog):
     assert re.search(re.compile(r"Platform: .*"), caplog.text)
     assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
     assert re.search(
-        re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
+        re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
     )
+
+
+@pytest.mark.skipif(psutil is None, reason="No psutil.")
+def test_fs_info_in_repo(dvc_repo, caplog):
+    assert main(["version"]) == 0
+
     assert re.search(
-        re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
+        re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
     )
     assert re.search(
-        re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
+        re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
     )
 
 
@@ -28,12 +36,18 @@ def test_info_outside_of_repo(repo_dir, caplog):
     assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
     assert re.search(re.compile(r"Platform: .*"), caplog.text)
     assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
+    assert not re.search(
+        re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
+    )
+
+
+@pytest.mark.skipif(psutil is None, reason="No psutil.")
+def test_fs_info_outside_of_repo(repo_dir, caplog):
+    assert main(["version"]) == 0
+
     assert re.search(
         re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
     )
     assert not re.search(
         re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
     )
-    assert not re.search(
-        re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
-    )

pip install -e .[all]
parse_log_pytest
pytest
pytest pytest-timeout pytest-cov pytest-xdist pytest-mock flaky mock xmltodict awscli google-compute-engine Pygments collective.checkdocs flake8 psutil flake8-docstrings pydocstyle jaraco.windows mock-ssh-server moto rangehttpserver
apt-get update apt-get install -y gcc
3.7
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aliyun-python-sdk-core==2.16.0
aliyun-python-sdk-core-v3==2.13.33
aliyun-python-sdk-kms==2.16.5
appdirs==1.4.4
asciimatics==1.14.0
attrs @ file:///croot/attrs_1668696182826/work
autocommand==2.2.2
awscli==1.31.13
azure-common==1.1.28
azure-storage-blob==2.0.1
azure-storage-common==2.1.0
bcrypt==4.2.1
boto==2.49.0
boto3==1.9.115
botocore==1.12.253
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
collective.checkdocs==0.2
colorama==0.4.4
configobj==5.0.9
configparser==5.3.0
coverage==7.2.7
crcmod==1.7
cryptography==44.0.2
distro==1.9.0
docutils==0.15.2
-e git+https://github.com/iterative/dvc.git@32425e90691bfd4988eb0a2d70cdc4fdba910f49#egg=dvc
execnet==2.0.2
flake8==5.0.4
flake8-docstrings==1.7.0
flaky==3.8.1
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
funcy==2.0
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==1.34.1
google-auth==2.38.0
google-cloud-core==0.28.1
google-cloud-storage==1.13.0
google-compute-engine==2.8.13
google-crc32c==1.5.0
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
humanize==4.6.0
idna==3.10
importlib-metadata==4.2.0
importlib-resources==5.12.0
inflect==6.0.5
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
jaraco.classes==3.2.3
jaraco.collections==4.2.0
jaraco.context==4.3.0
jaraco.functools==3.7.0
jaraco.structures==2.1.0
jaraco.text==3.11.1
jaraco.ui==2.3.0
jaraco.windows==5.7.0
Jinja2==3.1.6
jmespath==0.10.0
jsonpath-ng==1.7.0
MarkupSafe==2.1.5
mccabe==0.7.0
mock==5.2.0
mock-ssh-server==0.9.1
more-itertools==9.1.0
moto==4.2.14
nanotime==0.5.2
networkx==2.6.3
numpy==1.21.6
oss2==2.6.1
packaging @ file:///croot/packaging_1671697413597/work
paramiko==3.5.1
path==16.6.0
pathspec==0.11.2
Pillow==9.5.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
ply==3.11
protobuf==3.20.3
psutil==7.0.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyarrow==0.14.0
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycodestyle==2.9.1
pycparser==2.21
pycryptodome==3.22.0
pydantic==1.10.21
pydocstyle==6.3.0
pyfiglet==0.8.post1
pyflakes==2.5.0
Pygments==2.17.2
PyNaCl==1.5.0
pyparsing==3.1.4
pytest==7.1.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-timeout==2.3.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
PyYAML==6.0.1
rangehttpserver==1.4.0
requests==2.31.0
responses==0.23.3
rsa==4.7.2
ruamel.yaml==0.15.100
s3transfer==0.2.1
schema==0.7.7
shortuuid==1.0.13
six==1.17.0
smmap==5.0.2
snowballstemmer==2.2.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
treelib==1.7.1
types-PyYAML==6.0.12.12
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
urllib3==1.25.11
wcwidth==0.2.13
Werkzeug==2.2.3
xmltodict==0.14.2
zc.lockfile==3.0.post1
zipp @ file:///croot/zipp_1672387121353/work

name: dvc
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
  - attrs=22.1.0=py37h06a4308_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - flit-core=3.6.0=pyhd3eb1b0_0
  - importlib_metadata=4.11.3=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - 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
  - packaging=22.0=py37h06a4308_0
  - pip=22.3.1=py37h06a4308_0
  - pluggy=1.0.0=py37h06a4308_1
  - py=1.11.0=pyhd3eb1b0_0
  - pytest=7.1.2=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py37h06a4308_0
  - typing_extensions=4.4.0=py37h06a4308_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.11.0=py37h06a4308_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aliyun-python-sdk-core==2.16.0
      - aliyun-python-sdk-core-v3==2.13.33
      - aliyun-python-sdk-kms==2.16.5
      - appdirs==1.4.4
      - asciimatics==1.14.0
      - autocommand==2.2.2
      - awscli==1.31.13
      - azure-common==1.1.28
      - azure-storage-blob==2.0.1
      - azure-storage-common==2.1.0
      - bcrypt==4.2.1
      - boto==2.49.0
      - boto3==1.9.115
      - botocore==1.12.253
      - cachetools==5.5.2
      - cffi==1.15.1
      - charset-normalizer==3.4.1
      - collective-checkdocs==0.2
      - colorama==0.4.4
      - configobj==5.0.9
      - configparser==5.3.0
      - coverage==7.2.7
      - crcmod==1.7
      - cryptography==44.0.2
      - distro==1.9.0
      - docutils==0.15.2
      - dvc==0.53.2
      - execnet==2.0.2
      - flake8==5.0.4
      - flake8-docstrings==1.7.0
      - flaky==3.8.1
      - funcy==2.0
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-api-core==1.34.1
      - google-auth==2.38.0
      - google-cloud-core==0.28.1
      - google-cloud-storage==1.13.0
      - google-compute-engine==2.8.13
      - google-crc32c==1.5.0
      - google-resumable-media==2.7.2
      - googleapis-common-protos==1.69.2
      - grandalf==0.6
      - humanize==4.6.0
      - idna==3.10
      - importlib-metadata==4.2.0
      - importlib-resources==5.12.0
      - inflect==6.0.5
      - jaraco-classes==3.2.3
      - jaraco-collections==4.2.0
      - jaraco-context==4.3.0
      - jaraco-functools==3.7.0
      - jaraco-structures==2.1.0
      - jaraco-text==3.11.1
      - jaraco-ui==2.3.0
      - jaraco-windows==5.7.0
      - jinja2==3.1.6
      - jmespath==0.10.0
      - jsonpath-ng==1.7.0
      - markupsafe==2.1.5
      - mccabe==0.7.0
      - mock==5.2.0
      - mock-ssh-server==0.9.1
      - more-itertools==9.1.0
      - moto==4.2.14
      - nanotime==0.5.2
      - networkx==2.6.3
      - numpy==1.21.6
      - oss2==2.6.1
      - paramiko==3.5.1
      - path==16.6.0
      - pathspec==0.11.2
      - pillow==9.5.0
      - ply==3.11
      - protobuf==3.20.3
      - psutil==7.0.0
      - pyarrow==0.14.0
      - pyasn1==0.5.1
      - pyasn1-modules==0.3.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pycryptodome==3.22.0
      - pydantic==1.10.21
      - pydocstyle==6.3.0
      - pyfiglet==0.8.post1
      - pyflakes==2.5.0
      - pygments==2.17.2
      - pynacl==1.5.0
      - pyparsing==3.1.4
      - pytest-cov==4.1.0
      - pytest-mock==3.11.1
      - pytest-timeout==2.3.1
      - pytest-xdist==3.5.0
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.1
      - rangehttpserver==1.4.0
      - requests==2.31.0
      - responses==0.23.3
      - rsa==4.7.2
      - ruamel-yaml==0.15.100
      - s3transfer==0.2.1
      - schema==0.7.7
      - shortuuid==1.0.13
      - six==1.17.0
      - smmap==5.0.2
      - snowballstemmer==2.2.0
      - treelib==1.7.1
      - types-pyyaml==6.0.12.12
      - urllib3==1.25.11
      - wcwidth==0.2.13
      - werkzeug==2.2.3
      - xmltodict==0.14.2
      - zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc

tests/func/test_install.py::TestInstall::test_should_append_hooks_if_file_already_exists tests/func/test_install.py::TestInstall::test_should_be_idempotent
tests/func/test_install.py::TestInstall::test_should_create_hooks tests/func/test_install.py::TestInstall::test_should_post_checkout_hook_checkout tests/func/test_install.py::TestInstall::test_should_pre_push_hook_push tests/func/test_version.py::test_info_in_repo tests/func/test_version.py::test_fs_info_in_repo tests/func/test_version.py::test_info_outside_of_repo tests/func/test_version.py::test_fs_info_outside_of_repo
dvc/command/version.py dvc/scm/git/__init__.py
dvc/command/version.py dvc/scm/git/__init__.py