Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用github从两台不同的计算机开发我的项目_Git_Github - Fatal编程技术网

如何使用github从两台不同的计算机开发我的项目

如何使用github从两台不同的计算机开发我的项目,git,github,Git,Github,我想有可能从两台不同的计算机开发我的laravel项目。 但我似乎做错了什么 我在PC1上创建了一个项目。 安装git for windows。 然后转到项目文件夹并初始化项目 git init git init 然后添加我想与Github同步的文件和文件夹 git add README.md composer.json app resources tests artisan config package.json routes bootstrap database phpunit.xml

我想有可能从两台不同的计算机开发我的laravel项目。 但我似乎做错了什么

我在PC1上创建了一个项目。 安装git for windows。 然后转到项目文件夹并初始化项目

git init
git init
然后添加我想与Github同步的文件和文件夹

git add README.md  composer.json app resources tests artisan config package.json routes bootstrap database phpunit.xml server.php webpack.mix.js
先做承诺

git commit -m "first commit"
在GitHub上创建与空存储库的链接

git remote add origin https://github.com/my/repo.git
将本地文件上载到Github

git push -f origin master
如果没有f git,则返回一个错误。我不知道如何解决,但据我所知,GitHub回购协议是空的,我没有任何损失,我只是使用武力,这是正常的

第一步已经完成。 我有一个与GitHub同步的PC1项目

现在我想在PC2上克隆这个项目

我创建了一个全新的laravel项目

laravel new blog
将我的项目文件从GitHub克隆到临时文件夹,然后将其移动到博客文件夹

git clone https://github.com/my/repo.git
转到项目文件夹并初始化项目

git init
git init
使用GitHub存储库创建链接

git remote add origin https://github.com/my/repo.git
添加我想与GitHub同步的文件和文件夹

git add README.md  composer.json app resources tests artisan config package.json routes bootstrap database phpunit.xml server.php webpack.mix.js
然后,如果我执行git状态,我会看到我从GitHub克隆的所有文件都标记为提交 所以我有点困惑该怎么办

git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   README.md
        new file:   app/Admin/Controllers/AuthController.php
        new file:   app/Admin/Controllers/ExampleController.php
        new file:   app/Admin/Controllers/FurnituraController.php
        new file:   app/Admin/Controllers/HomeController.php
        new file:   app/Admin/Controllers/NewsController.php
        ....

git状态
论分行行长
还没有承诺
要提交的更改:
(使用“git rm--cached…”取消存储)
新文件:README.md
新文件:app/Admin/Controllers/AuthController.php
新文件:app/Admin/Controllers/ExampleController.php
新文件:app/Admin/Controllers/FurnituraController.php
新文件:app/Admin/Controllers/HomeController.php
新文件:app/Admin/Controllers/NewsController.php
....

您不应
git init
将现有存储库添加为远程存储库。
git克隆应该足够了

您可以添加所有文件,减去,而不是子集。

请参阅

中的“”,您正在执行设置PC2完全错误的部分。遵循本指南,在PC2阶段您应该做的就是git克隆。就这样,你已经准备好工作了。我又测试了几次,真的PC2
git clone
就足够了。但我不明白为什么在第一次从PC1推送到github上的fresh repo(只包含readme.md)后,我出现了错误,并且只能使用F keygit push-u origin master进行推送![已拒绝]主控->主控(先提取)错误:无法将某些引用推送到“”提示:更新被拒绝,因为远程包含您所做的工作