问题
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.
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.
From the documentation:
$ git init
This creates a new subdirectory named
.git
that contains all of your necessary repository files – a Git repository skeleton.
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?
回答1:
Except if you have used the --git-dir
option when running "git init", your .git
directory MUST be in the directory. Perhaps you should look more carefully.
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-init Remove this env variable if it's the case.
And the added (staged) files are stored in the index
file stored inside this .git
directory...
dir -AH
(in powershell? otherwise it's dir /AH
) works well for me...
回答2:
A git init myrepo
would always create an empty myrepo/
folder, with the myrepo/.git
in it ready to get data.
A git init --bare myrepo.git
is for creating a bare repo you can push to:
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)
You wouldn't see file.txt
on myrepo.git
upstream repo though, since a bare repo has no working tree (hence "bare")
In the repo, myrepo/.git/objects
would contain the objects you are adding to the local repo: see Git Internals - Git Objects.
From gotgit:
回答3:
Do
git rev-parse --git-dir
to see where git's finding the repository structure.
@VonC's got the goods on where the objects are, I'll just add that everything else is repo-local metadata.
回答4:
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.
回答5:
If you're using Windows, make sure you have your folder configured like this:
This is to show the hide elements
回答6:
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
git init --bare Project1
cd C:\Users\JimPC\Documents\MyJava
git clone C:\Users\JimPC\Documents\pretendCloud\Project1 Project1
cd Project1
dir >File01.txt
git add File01.txt
git commit -m "Initial State Commit"
git push -u origin master
After these commands, I believe I am ready to continue building my project on the master branch.
回答7:
It looks to me like it's simply not creating a repository. I run these commands in Windows 7:
c:\Windows\System32>git init project1
Reinitialized existing Git repository in c:/Windows/System32/project1/.git/
c:\Windows\System32>cd project1
The system cannot find the path specified.
c:\Windows\System32>cd c:/Windows/System32/project1
The system cannot find the path specified.
c:\Windows\System32>git rev-parse --git-dir
fatal: Not a git repository (or any of the parent directories): .git
c:\Windows\System32>
回答8:
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
来源:https://stackoverflow.com/questions/28914310/git-init-will-not-create-git-directories-for-me