Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheDude's avatar

Install Laravel on server and then git pull

composer create-project laravel/laravel src
cd src
git init
git remote add origin gitrepo/web.git
git remote set-url origin gitrepo/web.git
git checkout master
error:    The following untracked working tree files would be overwritten by checkout

I tried git stash and git clean but was unable to find a solution.

How can I approach this?

0 likes
7 replies
Sinnbeck's avatar

@the-dude ok. You don't create a laravel project there. You only pull. So delete that folder on the server and try just cloning

git clone gitrepo/web.git 
1 like
TheDude's avatar

@Sinnbeck

.gitignore

/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
*.sqlite
/.fleet
/.idea
/.vscode
.vscode/launch.json
/storage/app/public

if I push with this .gitignore

after git clone on the server what do I need to do? run composer? npm i? npm run build?

Just to reinterate I don't run composer create-project laravel/laravel on the server right?

Could of sworn I installed using composer and then did a git pull last time, but it didnt work this time.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@the-dude you run composer install and set up your env file. If you need to compile assets on production you run npm install and `npm run build[

1 like
Sinnbeck's avatar

@the-dude Happy to help. And be aware that this is only the first time (setup). Next time you just do git pull and then composer install. And the npm commands if needed

Please or to participate in this conversation.