git : clone doesn't bring in all the files?
I just created directory called website
. This has a couple of images, index.html page etc. I ran : git --bare init --shared=0777
Now, it successfully created an empty shared repo.
I now try to clone this project by going into /developers/developer1
on my server and running git clone /live/website
. I get the following message:
Initialized empty Git repository in /developer/developer1/website/.git/
warning: You appear to have cloned an empty repository.
I'm running UNIX. When I do a ls
, all I see is the .git folder and none of the images/ index.html page have been cloned here. I tried to do:
git pull /live/website origin
fatal: Couldn't find remote ref origin
fatal: The remote end hung up unexpectedly
git pull /live/website master
fatal: Couldn't find remote ref master
fatal: The remote end hung up unexpectedly
I know I need to be doing origin
because when I do a git remote -v
, here's what I get:
origin /live/website (fetch)
origin /live/website (push)
So in a nutshell, here's what I need help doing:
- Figure out how to clone all my files from /live/website to /developer1
- Be able to make changes to the files locally on developer1 and push those changes back.
However, since I can't seem to get the files in the first place, I can't really proceed! The major intention is to allow a lot of developer开发者_开发问答s to simultaneously work on the files and push their changes to the main /live/website
directory, once they are done.
You have to do some steps to get files into your repo. Assume you have a server where the bare repo is stored and some workstations where the actual work is done.
Initialize the bare repo on your server like you wrote:
git --bare init --shared=0777
Checkout this directory to your workstation1:
git clone git://server/repo.git
Drop some files into this freshly cloned repo and add them to the track. To add all of them, do a
git add .
Commit the added files to the local repository:
git commit -m 'initial commit'
Now, the changes (adding files) were stored in the local repository.Finally, push back the files (assuming you work on branch master) to the server (known as origin):
git push origin master
Now, do some more local changes and commit them to the local repo as in step 4. When you type
git status
now, it should give you a message like
Your branch is ahead of origin/whatever by 1 commit
To bring the changes back to the central repo, you can simply type
git push
since you set up the tracking of the branch in step 5.
Now, if you do a git clone git://server/repo.git
from another machine (e.g. workstation2), you will get the files you just checked in...
That's the general git workflow:
- Get the files from the server (initial:
clone
, consecutivepull
) - Do some changes and store them in the local repo (
git commit
) - When the time has come, push back the local commits to the bare repo (
git push
)
To get a more detailed explanation, see the section Private Small Team in the online version of the progit book.
when you create a repository with git init
it starts as an empty repository. you have to add files (git add -- file1 file2 other files
) first and then create a commit (git commit -m'initial commit'
).
you should then be able to clone said repository using git clone
and fetch/pull from it
精彩评论