git init 不会为我创建 git 目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28914310/
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
git init will not create git directories for me
提问by jmknpk
I am new to Git.
I can get a Git directory structure in a bare directory with git -init --bare
.
I can see where the git information is stored.
我是 Git 的新手。我可以在一个裸目录中获得一个 Git 目录结构git -init --bare
。我可以看到git信息的存储位置。
However, when I try to use git init
or even git clone
, I never see any .git
subdirectory in my local repository. I can add files and push, but have no idea where those files are actually stored on disk for my local repository.
但是,当我尝试使用git init
甚至 时git clone
,我从未.git
在本地存储库中看到任何子目录。我可以添加文件和推送,但不知道这些文件实际上存储在我本地存储库的磁盘上的哪个位置。
From the documentation:
从文档:
$ git init
This creates a new subdirectory named
.git
that contains all of your necessary repository files – a Git repository skeleton.
$ git init
这会创建一个名为的新子目录
.git
,其中包含所有必需的存储库文件——一个 Git 存储库框架。
However, I never see that skeleton directory. I have used dir -AH
to see if the git directory is hidden, but there is none. Why do I not get a git skeleton directory? And where, exactly are the added (staged) files put?
但是,我从来没有看到那个骨架目录。以前dir -AH
看git目录有没有隐藏,但是没有。为什么我没有得到 git 框架目录?添加的(暂存的)文件究竟放在哪里?
采纳答案by Philippe
Except if you have used the --git-dir
option when running "git init", your .git
directory MUSTbe in the directory. Perhaps you should look more carefully.
除非您--git-dir
在运行“git init”时使用了该选项,否则您的.git
目录必须在该目录中。也许你应该仔细看看。
In the same idea, perhaps have you set an environment variable GIT_DIR
that change the place where the .git
directory is stored. See http://git-scm.com/docs/git-initRemove this env variable if it's the case.
同样的想法,也许你设置了一个环境变量GIT_DIR
来改变.git
目录的存储位置。如果是这种情况,请参阅http://git-scm.com/docs/git-init删除此 env 变量。
And the added (staged) files are stored in the index
file stored inside this .git
directory...
并且添加的(暂存)文件存储在index
存储在此.git
目录中的文件中 ...
dir -AH
(in powershell? otherwise it's dir /AH
) works well for me...
dir -AH
(在powershell中?否则它dir /AH
)对我来说效果很好......
回答by multigoodverse
On Windows, git init
may create a hidden .git folder. Go to Organize --> Files and Search Options --> and then check Show Hidden Files. That will unveil the .git folder.
在 Windows 上,git init
可能会创建一个隐藏的 .git 文件夹。转到组织 --> 文件和搜索选项 --> 然后选中显示隐藏文件。这将揭开 .git 文件夹的面纱。
回答by VonC
A git init myrepo
would always create an empty myrepo/
folder, with the myrepo/.git
in it ready to get data.
Agit init myrepo
将始终创建一个空myrepo/
文件夹,myrepo/.git
在其中准备好获取数据。
A git init --bare myrepo.git
is for creating a bare repo you can push to:
Agit init --bare myrepo.git
用于创建您可以推送到的裸仓库:
cd myrepo
git remote add origin ../myrepo.git
touch file.txt
git add .
git commit -m "First commit"
git push -u origin master
(Picture from gotgit)
(图片来自gotgit)
You wouldn't see file.txt
on myrepo.git
upstream repothough, since a bare repohas no working tree (hence "bare")
但是,您不会file.txt
在myrepo.git
上游回购中看到,因为裸回购没有工作树(因此是“裸”)
In the repo, myrepo/.git/objects
would contain the objects you are adding to the local repo: see Git Internals - Git Objects.
From gotgit:
在 repo 中,myrepo/.git/objects
将包含您添加到本地 repo 的对象:请参阅Git Internals - Git Objects。
从gotgit:
回答by jthill
Do
做
git rev-parse --git-dir
to see where git's finding the repository structure.
查看 git 在哪里找到存储库结构。
@VonC's got the goods on where the objects are, I'll just add that everything else is repo-local metadata.
@VonC 已经了解了对象所在的位置,我只想补充一点,其他所有内容都是 repo-local 元数据。
回答by Carolina
If you're using Windows, make sure you have your folder configured like this:
如果您使用的是 Windows,请确保您的文件夹配置如下:
This is to show the hide elements
这是为了显示隐藏元素
回答by jmknpk
I am ultimately attmepting to create remote and local repositories completely from scratch. These are the commands I've used. If anyone has suggestions I'd gladly hear them.
我最终试图完全从头开始创建远程和本地存储库。这些是我使用过的命令。如果有人有建议,我很乐意听到。
cd C:\Users\JimPC\Documents\pretendCloud
cd C:\Users\JimPC\Documents\pretendCloud
git init --bare Project1
git init --bare Project1
cd C:\Users\JimPC\Documents\MyJava
cd C:\Users\JimPC\Documents\MyJava
git clone C:\Users\JimPC\Documents\pretendCloud\Project1 Project1
git clone C:\Users\JimPC\Documents\pretendCloud\Project1 Project1
cd Project1
光盘项目1
dir >File01.txt
目录 >File01.txt
git add File01.txt
git add File01.txt
git commit -m "Initial State Commit"
git commit -m "初始状态提交"
git push -u origin master
git push -u 原点大师
After these commands, I believe I am ready to continue building my project on the master branch.
执行完这些命令后,我相信我已经准备好在 master 分支上继续构建我的项目了。
回答by Steve OShaughnessy
It looks to me like it's simply not creating a repository. I run these commands in Windows 7:
在我看来,它只是没有创建存储库。我在 Windows 7 中运行这些命令:
c:\Windows\System32>git init project1
c:\Windows\System32>git init project1
Reinitialized existing Git repository in c:/Windows/System32/project1/.git/
在 c:/Windows/System32/project1/.git/ 中重新初始化现有的 Git 存储库
c:\Windows\System32>cd project1
c:\Windows\System32>cd project1
The system cannot find the path specified.
该系统找不到指定的路径。
c:\Windows\System32>cd c:/Windows/System32/project1
c:\Windows\System32>cd c:/Windows/System32/project1
The system cannot find the path specified.
该系统找不到指定的路径。
c:\Windows\System32>git rev-parse --git-dir
c:\Windows\System32>git rev-parse --git-dir
fatal: Not a git repository (or any of the parent directories): .git
致命:不是 git 存储库(或任何父目录):.git
c:\Windows\System32>
c:\Windows\System32>
回答by Rakesh yakkundi
if the directory is recornized then once you dissable the protection of pciif in case the git is installed in other then main drive and check again it will be created
如果目录被重新调整,那么一旦您禁用 pciif 的保护,以防 git 安装在其他主驱动器中并再次检查它将被创建