Reputation: 684
I want to have the possibility to develop my laravel project from 2 different computers. But it seems I do something wrong.
I created a project on PC1. Install git for windows. Then go to the project folder and initialize the project.
git init
Then add files and folders I want to be synchronized with Github
git add README.md composer.json app resources tests artisan config package.json routes bootstrap database phpunit.xml server.php webpack.mix.js
Do first commit
git commit -m "first commit"
Create a link with the empty repository on GitHub
git remote add origin https://github.com/my/repo.git
Upload local files to Github
git push -f origin master
WIthout f git returns an error. I don't know how to solve, but as far as I know, GitHub repo is empty and I have nothing to lost I just use force and it is OK.
The first step is done. I have a project on PC1 synchronized with GitHub.
Now I want to clone this project on PC2
I create a fresh laravel project.
laravel new blog
Clone my project files from GitHub to temporary folder and then move them to the blog folder.
git clone https://github.com/my/repo.git
Go to the project folder and initialize the project.
git init
Create a link with GitHub repository
git remote add origin https://github.com/my/repo.git
Add files and folders I want to be synchronized with GitHub
git add README.md composer.json app resources tests artisan config package.json routes bootstrap database phpunit.xml server.php webpack.mix.js
Then if I do git status I see that all files, which I cloned from GitHub are marked for commit So I am a little bit confused about what to do.
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
....
Upvotes: 1
Views: 164
Reputation: 1323045
You should not git init
and add your existing repository as remote.
The git clone
should be enough.
And you could add all the files, minus the .gitignore
for laravel project, instead of a subset.
See then "Connecting the Laravel Project on GitHub." from Ujala Jha.
Upvotes: 2