我不喜欢 git config --global
因为我使用了更多的帐户。
我也不喜欢每次都设置配置,我想克隆一些 repo。
我正在寻找这样的东西:
folder01/
..there is one clonned repo..
folderO2/
..there is two clonned repo..
git config <folder> user.email ...
我需要文件夹中的 repos 继承父文件夹的配置。
两个文件夹都不是 repos,只是文件夹。
我将 repos 克隆到某个文件夹中,有时我会删除一些 repo。
非常感谢!
最佳答案
如果你的系统只需要一个配置,你可以用git config --system
来配置它。 (作为管理员/root)。
如果您想为多个用户(但不是所有用户)使用相同的配置,您可以在每个用户的主目录中创建此配置和指向该配置的链接。
不可能直接这样做(至少我不知道)。
但是,有一些有趣的事情:
命令
git config
有一个--file option
.有了它,您可以配置单独的配置文件。您可以为您设置配置文件
git config --local include.path "<config file>"
.
有了它,你可以为你的目录创建一个新的配置文件,当你创建一个目录时,你可以使用 git config --local include.path "<config file>"
设置目录的配置文件。 .
您还可以通过编写脚本来自动执行此操作,该脚本会自动扫描所有目录,例如配置文件并执行 git config --local include.path "<config file>"
如果它找到任何文件。
该脚本可能看起来像那样(如果您使用 linux/bash):
#!/bin/bash
git init
initDir="$PWD"
while [ "$PWD" != "/" -a ! -f "./.gitconfig" ] ; do
cd ..
done
if [[ -f "./.gitconfig" ]]; then
configFile="$PWD/.gitconfig"
cd $initDir
git config --local include.path "$configFile"
fi
关于git - 带 repos 的文件夹的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57921814/