Git 忽略文件夹中的命令 - 它真的可以忽略它在 git 存储库中吗?
Git command within ignored folders - can it truly ignore that it is within a git repo?
我在我的主要用户目录中有一个 git 回购设置,以便在我的计算机之间同步配置,如下所示:
/Users/myusername/.versionedConfigFile
/Users/myusername/myOtherFolders <-- to be igored
/Users/myusername/projects/somerepo/.git <-- to be igored
除了这些配置文件之外,我希望在我的 git 存储库中忽略其他所有内容,这就是为什么我的 .gitignore 看起来像这样:
*
!.gitignore
!.versionedConfigFile
虽然 .gitignore 允许我从 tracking 中排除所有其他文件,但我仍然可以看到我在 git 存储库中例如,当我 cd 进入 "myOtherFolders" 和 运行 git 命令时,例如 "git status"。我更愿意在这里看到 "not a git repository",以免在我的目录树中使用其他 git 存储库时感到困惑(当然仍然有效)。
有没有办法"truly"从 .git 存储库中排除文件夹?
另一种选择是:
- 将您的 Git 存储库放在一个单独的位置,其中包含您的
.versionedConfigFile
- 在
/Users/myusername/.versionedConfigFile
中有一个指向该单独存储库的符号链接。
这样,您就不必忽略所有内容,并且可以在 /Users/myusername/
中拥有其他存储库。
我在我的主要用户目录中有一个 git 回购设置,以便在我的计算机之间同步配置,如下所示:
/Users/myusername/.versionedConfigFile
/Users/myusername/myOtherFolders <-- to be igored
/Users/myusername/projects/somerepo/.git <-- to be igored
除了这些配置文件之外,我希望在我的 git 存储库中忽略其他所有内容,这就是为什么我的 .gitignore 看起来像这样:
*
!.gitignore
!.versionedConfigFile
虽然 .gitignore 允许我从 tracking 中排除所有其他文件,但我仍然可以看到我在 git 存储库中例如,当我 cd 进入 "myOtherFolders" 和 运行 git 命令时,例如 "git status"。我更愿意在这里看到 "not a git repository",以免在我的目录树中使用其他 git 存储库时感到困惑(当然仍然有效)。
有没有办法"truly"从 .git 存储库中排除文件夹?
另一种选择是:
- 将您的 Git 存储库放在一个单独的位置,其中包含您的
.versionedConfigFile
- 在
/Users/myusername/.versionedConfigFile
中有一个指向该单独存储库的符号链接。
这样,您就不必忽略所有内容,并且可以在 /Users/myusername/
中拥有其他存储库。