简体   繁体   English

Git在Windows中更改'.git'文件夹名称

[英]Git change '.git' folder name in windows

By default git init creates a folder called '.git'. 默认情况下,git init会创建一个名为“.git”的文件夹。 In the recent Visual Studio tools (2005 and up) this works fine. 在最近的Visual Studio工具(2005及更高版本)中,这很好用。 But Visual Studio 2003 (and ... VB6 as well probably) crashes on this foldername. 但Visual Studio 2003(以及......可能是VB6)在这个foldername上崩溃了。 ideally I would like to change this per repository to something like 'git' instead of '.git'. 理想情况下,我想将每个存储库更改为'git'而不是'.git'。 Is this possible? 这可能吗?

I know this has been asked before ( relocating the .git folder ) ... but that was in a linux environment. 我知道之前已经问过这个问题( 重新定位.git文件夹 )......但那是在linux环境中。 I'm using windows at work sigh . 我在工作时叹了口气

Hoping there is a simple solution .. otherwise I'll just have to wing it :o But I would rather use sexy git. 希望有一个简单的解决方案..否则我只需要避开它:o但我宁愿使用性感的git。

edit: 编辑:

How do you set the GIT_DIR variable on windows? 如何在Windows上设置GIT_DIR变量? I googled it but it didn't make much sense. 我用谷歌搜索它,但它没有多大意义。

edit2: EDIT2:

Wouldn't an environment variable set it for all repositories on that machine? 环境变量不会为该计算机上的所有存储库设置它吗? If so I would have to go into every repository and move the folder manually ... also, I tried setting it to 'git' and when I open the git gui app it tells me "cannot use funny .git repository git". 如果是这样,我将不得不进入每个存储库并手动移动文件夹...另外,我尝试将其设置为'git',当我打开git gui应用程序时,它告诉我“不能使用有趣的.git存储库git”。 When I use the git console it works ... but honestly this is far from a good solution. 当我使用git控制台时它可以工作......但老实说,这远非一个好的解决方案。

GIT_DIR变量允许您为存储库指定另一个位置。

On Linux, at least, git has a command line option called --git-dir . 至少在Linux上,git有一个名为--git-dir的命令行选项。 Whenever you run git, use the --git-dir option. 每当你运行git时,使用--git-dir选项。 This should exist in the Windows version too, so you could do 这应该存在于Windows版本中,所以你可以这样做

 git --git-dir=git_directory status

Perhaps you could put that in a batch file or something to make your life easier. 也许您可以将其放在批处理文件或其他东西中,以使您的生活更轻松。

您应该能够使用此知识库指南设置GIT_DIR环境变量。

I'd suppose the easiest way is to not have any .sln files in the project root. 我想最简单的方法是在项目根目录中没有任何.sln文件。

The project here has about 50 .sln files. 这个项目有大约50个.sln文件。

在存储库根目录下至少创建一个级别的所有项目。

as already suggested by Michael 正如迈克尔已经建议的那样

use 采用

--git-dir=dirname

This works on Windows and Linux 这适用于Windows和Linux

The command must come after the specification of the directory. 该命令必须在指定目录之后。

git --git-dir=.git1234 status

this will not work 这不行

git status --git-dir=.git1234 

Also git will not ignore .git1234 as it will .git so make sure you add your new dir name to your .gitignore file 另外git不会忽略.git1234,因为它会.git所以请确保将新的dir名称添加到.gitignore文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM