Php 从github覆盖本地磁盘上的文件(使用Laravel框架)
我正在努力做到以下几点: 1) 使用以下内容创建新的laravel项目:Php 从github覆盖本地磁盘上的文件(使用Laravel框架),php,git,laravel,github,laravel-5,Php,Git,Laravel,Github,Laravel 5,我正在努力做到以下几点: 1) 使用以下内容创建新的laravel项目: sudo composer create-project laravel/laravel /var/www/html/laravel5` 2) 仅覆盖github中的不同文件。我想保持以下文件和文件夹不变: .env .env.example .gittributes .gitignore vendor/ 从github克隆不工作,因为文件夹不是空的 我发现的唯一解决办法是: 创建新项目 将我想要的文件和文件夹复制到
sudo composer create-project laravel/laravel /var/www/html/laravel5`
2) 仅覆盖github中的不同文件。我想保持以下文件和文件夹不变:
.env
.env.example
.gittributes
.gitignore
vendor/
提前感谢。您应该能够通过一个全git方法来完成这项工作,而不是从另一个目录复制/粘贴。(不过,我不知道为什么您的变通方案是一个糟糕的解决方案。) 基本计划是:
cd /path/to/repo
git init
git branch temp-branch
git add .env && git add .env.example && git add .gitattributes && git add .gitignore && git add vendor/
git commit -m "Sustain Local Changes"
git remote add origin https://github.com/owner/repo
git fetch
git checkout -f master # Should detect origin/master. If it doesn't, just set a branch up manually. Replace master if that's not the branch you want.
git merge --no-commit --no-ff temp-branch
就我个人而言,我觉得这比您的解决方案要难看得多。您所说的“仅覆盖github中的不同文件”是什么意思?您从哪个git repo克隆?我的存储库。我想保留使用“laravel new”命令创建的文件。我意识到您在合并时可能有冲突。如果是这样,只需使用-X命令之一。可能是他们的。