我使用Laravel Forge和BitBucket部署我的网络应用程序。最近我编写了我网站的一部分,我注意到我在CSS中犯了一个小错误,因为我无法使用git push
,因为我还没有完成编码,我改变了CSS使用FTP。所以在我完成开发之后,我尝试git push
但是我得到了这个错误(在Laravel Forge日志中):
error: Your local changes to the following files would be overwritten by merge:
在我搜索互联网后,我发现存储会解决问题所以我将部署脚本更改为:
cd /home/forge/default
git stash
git pull origin master
git stash apply stash@{0}
composer install
php artisan migrate --force
但现在我收到了这个错误:
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: empty ident name (for <forge@objavi.net>) not allowed
Cannot save the current index state
From bitbucket.org:alenn/objavi
* branch master -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
app/models/Post.php
app/models/User.php
app/routes.php
app/views/home.blade.php
app/views/layouts/partials/top.blade.php
app/views/main.blade.php
public/css/main.css
public/js/script.js
Please, commit your changes or stash them before you can merge.
error: The following untracked working tree files would be overwritten by merge:
app/views/users/readlater.blade.php
Please move or remove them before you can merge.
Aborting
有人可以帮我解决这个问题吗?
答案 0 :(得分:2)
当我必须像这样对服务器进行小修复时,我的标准程序是,一旦我将修复程序放入我的代码中,运行git checkout -- [filename]
或git checkout -- .
以重置已更改的文件或所有文件(如果你在很多地方都在捣乱)。
我从未尝试过git stash
方法,但您的服务器不应该是一个正常工作的目录,它应该只是接收您的代码。
另外,早期分支,经常分支。在功能分支中进行开发可以让git checkout master
,制作和推送您的修复,git checkout feature-branch
,然后git merge master
将您的修补程序带入您的功能分支并继续编码而无需直接更改文件服务器