没有 .git 存储库文件夹显示,使用 Windows 7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11766147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No .git repository folder showing, using windows 7
提问by James30
I am new to git (mysysgit) and I am trying to get it working on my laptop. I'm using windows 7. I have been able to use most of the commands but i don't think it's being saved anywhere. I used git init, git add ., git commit. All seemed to work fine but I am not able to find my .git folder anywhere. After using SmartGit I see nothing is being saved. What could be the problem?
我是 git (mysysgit) 的新手,我正在尝试让它在我的笔记本电脑上运行。我使用的是 Windows 7。我已经能够使用大部分命令,但我认为它没有被保存在任何地方。我使用了 git init、git add .、git commit。一切似乎都很好,但我无法在任何地方找到我的 .git 文件夹。使用 SmartGit 后,我看到没有保存任何内容。可能是什么问题呢?
采纳答案by grahamesd
If git inited, added and committed the folder with no problem then there is a .git folder there. If you can't see it in Windows Explorer then you need to enable the showing of hidden and system files and folders in Windows Explorer.
如果 git 初始化、添加和提交文件夹没有问题,那么那里有一个 .git 文件夹。如果您在 Windows 资源管理器中看不到它,那么您需要在 Windows 资源管理器中启用隐藏和系统文件和文件夹的显示。
The free eBook "Pro Git" is really helpful for getting up to speed with git. There is also another free one called "Git Succincly" that you have to register for but it's an undercut to Pro Git and I've not had any spam or annoying followups from it.
免费的电子书“ Pro Git”对于快速使用 git 非常有帮助。还有另一个名为“ Git Succincly”的免费软件,您必须注册,但它是 Pro Git 的一个削弱,而且我没有收到任何垃圾邮件或烦人的后续邮件。
Hope that helps.
希望有帮助。
回答by VonC
With git 2.9, the .git/
folder remains hidden by default, but now has a new config:
在 git 2.9 中,该.git/
文件夹默认保持隐藏状态,但现在有了新的配置:
git config core.hideDotFile dotGitOnly
That new setting allows to configure how to hide or not dot files.
该新设置允许配置如何隐藏或不隐藏点文件。
See commit ebf31e7, commit f30afda(11 May 2016) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
--in commit bfc99b6, 17 May 2016)
请参阅Johannes Schindelin ( ) 的commit ebf31e7和commit f30afda(2016 年 5 月 11 日)。(由Junio C Hamano合并-- --在提交 bfc99b6,2016 年 5 月 17 日)dscho
gitster
mingw
: introduce the 'core.hideDotFiles
' setting:On Unix (and Linux), files and directories whose names start with a dot are usually not shown by default. This convention is used by Git: the
.git/
directory should be left alone by regular users, and only accessed through Git itself.On Windows, no such convention exists. Instead, there is an explicit flag to mark files or directories as hidden.
In the early days, Git for Windows did not mark the
.git/
directory (or for that matter, any file or directory whose name starts with a dot) hidden. This lead to quite a bit of confusion, and even loss of data.Consequently, Git for Windows introduced the
core.hideDotFiles
setting, with three possible values: true, false, anddotGitOnly
, defaulting to marking only the.git/
directory as hidden (dotGitOnly
).The rationale: users do not need to access
.git/
directly, and indeed (as was demonstrated) should not really see that directory, either.
However, not all dot files should be hidden by default, as e.g. Eclipse does not show them (and the user would therefore be unable to see, say, a.gitattributes
file).In over five years since the last attempt to bring this patch into core Git, a slightly buggy version of this patch has served Git for Windows' users well: no single report indicated problems with the hidden
.git/
directory, and the stream of problems caused by the previously non-hidden.git/
directory simply stopped.
The bugs have been fixed during the process of getting this patch upstream.
mingw
: 介绍 'core.hideDotFiles
' 设置:在 Unix(和 Linux)上,名称以点开头的文件和目录通常默认不显示。Git 使用这个约定:
.git/
目录应该由普通用户单独留下,并且只能通过 Git 本身访问。在 Windows 上,不存在这样的约定。相反,有一个显式标志将文件或目录标记为 hidden。
在早期,Git for Windows 并没有将
.git/
目录(或者任何名称以点开头的文件或目录)标记为隐藏。这会导致相当多的混乱,甚至丢失数据。因此,Git for Windows 引入了该
core.hideDotFiles
设置,具有三个可能的值:true、false 和dotGitOnly
,默认仅将.git/
目录标记为隐藏 (dotGitOnly
)。基本原理:用户不需要
.git/
直接访问,实际上(正如所演示的)也不应该真正看到该目录。
然而,并不是所有的点文件都应该在默认情况下隐藏,例如 Eclipse 不会显示它们(因此用户将无法看到,比如说,一个.gitattributes
文件)。自从上次尝试将这个补丁引入核心 Git 以来的五年多时间里,这个补丁的一个稍微有缺陷的版本已经很好地为 Windows 用户服务了 Git:没有一份报告表明隐藏
.git/
目录存在问题,以及由隐藏目录引起的问题流。以前非隐藏.git/
目录只是停止。
在向上游获取此补丁的过程中,这些错误已得到修复。
The git config
man pagenow include:
该git config
手册页现在包括:
core.hideDotFiles
(Windows-only) If true, mark newly-created directories and files whose name starts with a dot as hidden.
If 'dotGitOnly
', only the.git/
directory is hidden, but no other files starting with a dot.
The default mode is 'dotGitOnly
'.
(仅限 Windows)如果为 true,则将名称以点开头的新创建的目录和文件标记为隐藏。
如果为“dotGitOnly
”,则仅.git/
隐藏目录,而不会隐藏其他以点开头的文件。
默认模式为“dotGitOnly
”。
回答by seanv
Although I have the Windows Explorer option selected to show hidden files and folders (and even show protected operating system files) the .git folder is still not visible. I pressed <F5> and it still doesn't show up.
尽管我选择了 Windows 资源管理器选项来显示隐藏的文件和文件夹(甚至显示受保护的操作系统文件),但 .git 文件夹仍然不可见。我按了 <F5> 但它仍然没有出现。
However, at the command prompt I can see it by typing
但是,在命令提示符下,我可以通过键入来查看它
dir /ah
from the repository directory.
从存储库目录。
After some time, the .git file finally showed up in Windows Explorer as well. I suspect Explorer hadn't received a callback notification that the directory had changed yet, and apparently <F5> doesn't override that...for hidden files. Or maybe Windows Explorer was apprehensive at first about showing a dotted andhidden file (folder) for the first time. :>
一段时间后,.git 文件也终于出现在 Windows 资源管理器中。我怀疑资源管理器还没有收到目录已更改的回调通知,显然 <F5> 没有覆盖...隐藏文件。或者,也许Windows资源管理器刚开始的时候呈现出点忧虑,并首次隐藏的文件(文件夹)。:>
回答by Prakash Rajendran
I installed git version 1.9.2 and was working with it using command line. Initially i was not able see the .git folder in my git repository but after changing the settings in windows to show the hidden files and folders, i am able to see the .git folder in my repository..!!
我安装了 git 版本 1.9.2 并使用命令行使用它。最初我无法在我的 git 存储库中看到 .git 文件夹,但是在更改 Windows 中的设置以显示隐藏的文件和文件夹后,我可以在我的存储库中看到 .git 文件夹..!!