git:克隆没有引入所有的文件? [英] git : clone doesn't bring in all the files?

查看:176
本文介绍了git:克隆没有引入所有的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚创建了名为网站的目录。这有几张图片,index.html页面等等。我跑了: git --bare init --shared = 0777


$ b $



我现在尝试克隆这个项目,方法是进入 / developers / developer1 并运行 git clone / live / website 。我收到以下消息:

$ p $ 在/developer/developer1/website/.git/
中初始化空的Git存储库:您似乎克隆了一个空的存储库。

我正在运行UNIX。当我做一个 ls 时,我所看到的只是.git文件夹,并且这里没有任何images / index.html页面被克隆。我试图做:

  git pull / live / website origin 
致命错误:无法找到远程参考源
致命:远程端意外挂起

git pull / live / website master
致命:无法找到远程参考大师
致命:远程端挂断意外地

我知道我需要做 origin 因为当我做一个 git remote -v 时,下面是我得到的结果:

 <$ c 
























$所以简而言之,这就是我需要帮助的方法:


  1. 弄清楚如何将所有文件从/ live / website复制到/ developer1

  2. 能够在developer1上本地更改文件,并将这些更改推回。



然而,由于我似乎无法得到这些文件,所以我不能真正开始!主要目的是允许许多开发人员同时处理这些文件,并在完成后将其更改推送到主要 / live / website 目录。

解决方案

您必须执行一些步骤才能将文件放入回购站。假设您有一台服务器,其中存储裸回购存储以及一些实际工作完成的工作站。


  1. 初始化裸回购您的服务器就像您写道:
    git --bare init --shared = 0777


  2. 将此目录签出到您的 workstation1
    git clone git://server/repo.git


  3. 将一些文件放入新鲜克隆的回购站中,并将它们添加到曲目中。要添加所有这些文件,请执行 git add。


  4. 将添加的文件提交到本地存储库:
    git commit -m'initial commit'

    现在,更改(添加文件)存储在本地存储库中。


  5. 最后,将文件(假设您在分支 master 上运行)推回到服务器(称为 origin ):

    git push origin master


  6. 现在,一些更多的本地更改并将它们提交到本地回购,如步骤4所示。现在,当您键入 git status 时,它应该会显示一条消息,如

    您的分支在原点之前/无论1 commit


  7. 要将更改返回到中央你可以简单地键入 git push ,因为你在步骤5中设置了分支的跟踪。


现在,如果您从另一台机器(例如 workstation2)执行 git clone git://server/repo.git ),哟你会得到你刚刚签入的文件...



这是一般的git工作流程:


  • 从服务器获取文件(初始: clone ,连续 pull

  • 做一些改变并将它们存储在本地仓库( git commit

  • 当时间到了,推回本地提交裸露的回购( git push



获取更详细的解释,请参阅部分>修改书


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:

  1. Figure out how to clone all my files from /live/website to /developer1
  2. 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 developers 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.

  1. Initialize the bare repo on your server like you wrote:
    git --bare init --shared=0777

  2. Checkout this directory to your workstation1:
    git clone git://server/repo.git

  3. Drop some files into this freshly cloned repo and add them to the track. To add all of them, do a git add .

  4. Commit the added files to the local repository:
    git commit -m 'initial commit'
    Now, the changes (adding files) were stored in the local repository.

  5. Finally, push back the files (assuming you work on branch master) to the server (known as origin):
    git push origin master

  6. 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

  7. 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, consecutive pull)
  • 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.

这篇关于git:克隆没有引入所有的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆