当使用git config——global来设置时,它会写入哪个文件?
例子:
git config --global core.editor "blah"
我在这些地方都找不到:
C:\Program Files\Git\etc\gitconfig
C:\myapp\.git\config
我没有设置ENV?
我的Git版本:1.6.5.1.1367。gcd48 - 在Windows 7上
当使用git config——global来设置时,它会写入哪个文件?
例子:
git config --global core.editor "blah"
我在这些地方都找不到:
C:\Program Files\Git\etc\gitconfig
C:\myapp\.git\config
我没有设置ENV?
我的Git版本:1.6.5.1.1367。gcd48 - 在Windows 7上
当前回答
卸载Msysgit,安装Cygwin + Git。然后是global '。C:\cygwin(64)\home\[userName]\。gitconfig。
现在你不必担心可能被其他程序使用的环境变量。例如,我的环境变量将我指向工作windows域环境中的一个映射驱动器。我不希望我的全局。gitconfig位于我的“home”映射驱动器上。我也不知道其他可能依赖于windows环境变量的应用程序会发生什么。由于某种原因,操作部门可能需要将该环境变量设置为映射的驱动器。
此外,你不必担心Mysysgit覆盖你的'配置文件'配置设置,如果你指定一个特定的路径全局'。Gitconfig ',使用这个方法。
一般来说,节省自己,在窗口中使用cygwin bash shell会更快乐
其他回答
我认为这句话很重要:
Git for Windows supports four levels of configuration. At the lowest level is the machine specific configuration settings known as "portable" and lives a "%ProgramData%\Git\config". One priority level us the installation specific configuration settings known as "system", which live at "\mingw64\etc\gitconfig". Both of these configuration file, generally require elevated privileges to modify. Starting with the use specific values known as "global" configuration, which can be found at "%UserProfile%.gitconfig", we find the "user editable" configuration files. The highest priority configuration settings are in the "local" configuration, which can usually be found at ".git\config". It see the recommendation in the blog linked is to modify the "system" or "installation" specific configuration settings, which is fine but users should expect that other installations of Git would not absorb said settings. If you want machine wide settings, use the "portable" configuration file, otherwise choose the "global" or "local" configuration files. Hopefully, people find this information useful.
源
什么时候创建全局的.gitconfig文件?
首先,git在安装过程中不会自动创建全局配置文件(.gitconfig)。该文件直到第一次写入时才被创建。如果您从未设置过系统变量,那么它就不会在您的文件系统上。我猜这可能就是问题的根源。
要求Git创建它的一种方法是请求编辑。这样做将强制创建文件。
Git配置——global——edit
如果在发出此命令时监视用户的主文件夹,您将看到.gitconfig文件神奇地出现。
git配置存储在哪里?
以下是与三个Git作用域(即系统、全局和本地)相关的配置文件的名称和位置的快速概述:
系统Git配置:文件名为gitconfig,位于- Git -install-location-/ming<32>/etc Git全局配置:位于用户主文件夹(C:\Users\ Git用户)的文件名为.gitconfig 本地Git配置:在本地repo的.git文件夹中命名为config的文件
当然,眼见为实,所以这里有一个图像显示每个文件和每个位置。我从我写的一篇关于这个主题的文章中截取了这张图片。
Windows Git配置文件位置:TheServerSide.com
全局位置是在Windows MsysGit上使用HOMEDRIVE和HOMEPATH环境变量派生的,除非您已经定义了HOME环境变量。在'profile'脚本中详细描述。
在我的公司环境中,HOMEDRIVE是H:,然后映射到一个网络URL \\share\$。然后,所有的文件都被映射为“我的文件”,这不是其他人所期望的。URL重映射的驱动器可能存在进一步的问题。我甚至无法调整HOMEDRIVE或HOMEPATH变量。
在我的情况下,我已经定义了一个个人HOME环境变量,并将其指向D:\git\GitHOME,并将所有这些git文件(没有和扩展名)复制到GitHOME目录以安全保存。
windows环境变量可以通过“我的电脑”属性对话框中的“高级”选项卡设置。
我把Git安装在:C:\Users\_myuserfolder_\AppData\Local\Programs\Git
我还在我的Windows机器上寻找全局的.gitconfig,并用git找到了这个巧妙的技巧。
执行a: gitconfig——global -e,然后,如果你幸运的话,你会得到一个文本编辑器加载你的全局.gitconfig文件。只需从那里查找文件夹(或尝试另存为…),等voilà!: -)