由于我修改了文件AuthenticatesUsers.php,无法进行git pull操作。

huangapple go评论51阅读模式
英文:

Cannot make git pull because of the file AuthenticatesUsers.php that I modified

问题

我在myproject_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php文件中进行了一些修改,然后将修改与其他文件一起推送。当我尝试进行git pull时,出现了错误:

error: Your local changes to the following files would be overwritten by merge:
        myproject_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php
Please commit your changes or stash them before you merge.
Aborting

那么如何修复这个问题?我尝试将tokenlite_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php添加到.gitignore文件中,但是得到了相同的结果。

英文:

I made some modifications in the myproject_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php; then I pushed the modifications with other files. When I tried to make git pull then I got error :

error: Your local changes to the following files would be overwritten by merge:
        myproject_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php
Please commit your changes or stash them before you merge.
Aborting

So how to fix it ? I tried to add tokenlite_app/vendor/laravel/ui/auth-backend/AuthenticatesUsers.php in the .gitignore file which I pushed after receiving the error, but got same results

答案1

得分: 1

在大多数情况下,Git提供的信息已经足够解决你在Git中遇到的问题。

"在合并之前,请提交你的更改或将其存储起来。"

根据错误信息,文件vendor/laravel/ui/auth-backend/AuthenticatesUsers.php仍在被修改,你可以使用以下命令将其恢复:

git checkout vendor/laravel/ui/auth-backend/AuthenticatesUsers.php

或者

git restore <file>

如果你确实需要更新该文件,你可以直接提交它,但最好不要直接更新供应商文件,如果你真的迫切需要更新它,最好是先fork一份。或者检查该软件包是否有一些发布机制。

删除供应商文件等操作是无效的,因为你已经将供应商文件推送到仓库中,执行composer install/update只会生成一个新的供应商文件,你需要再次提交和推送新的供应商文件,并合并它,如果多个开发人员在同一个仓库上工作,可能会出现合并冲突的情况。

另外,如果你已经将文件推送到仓库中,后续忽略该文件并不像简单地将文件路径添加到.gitignore那样简单,你需要在添加到.gitignore后执行一些额外的步骤。请参考Stackoverflow上的这个问题获取更多信息:https://stackoverflow.com/a/1139797/8630903

英文:

In most cases, the message Git provides is more than enough to solve the issue you are facing in the git.

"Please commit your changes or stash them before you merge."

Seeing the error the file vendor/laravel/ui/auth-backend/AuthenticatesUsers.php is still being modified either restore it back using

git checkout vendor/laravel/ui/auth-backend/AuthenticatesUsers.php

or

git restore &lt;file&gt;

You can just commit that file if you really need to update it, but vendor files should not be updated directly, it is better to fork if you are really in desperate need to update it. Or check if the package has some publish mechanism.

Deleting the vendors and such will not work since you have already pushed the vendor to the repo and doing composer install/update will just generate a new one which you need to again commit and push the new vendors and merge that, with the chance of merge conflicts if multiple developers are working on that repo.

Also, if you have already pushed the files to the repo, ignoring it afterwards is not simple like just adding that file path to .gitignore, you will need to follow a few more steps after adding on the .gitignore.
Follow this Stackoverflow question for more info https://stackoverflow.com/a/1139797/8630903

答案2

得分: 0

在谷歌搜索后,我执行了git reset --hard命令,然后执行了composer update命令。

英文:

After googling I made a git reset --hard, then I made composer update.

huangapple
  • 本文由 发表于 2023年7月27日 15:28:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76777414.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定