Home > database >  Can't merge a branch in git
Can't merge a branch in git

Time:01-02

error: Your local changes to the following files would be overwritten by merge:
        bootstrap/cache/services.php
Please commit your changes or stash them before you merge.
Aborting

I discard the change, then again it automatically changes added, how to fix it ?

CodePudding user response:

If you are discarding your change, but it then gets quickly re-written, then something outside of Git must be modifying the file. Since the file happens to be in a directory called "cache" my guess is you probably shouldn't be tracking that folder at all. (I recommend confirming this first.) If you add that cache folder to your .gitignore, and also delete it and commit the deletion so you no longer track it, then the next time it's auto-created and/or updated it will be properly ignored.

CodePudding user response:

If you don't want to keep your local changes, use the command :

git reset --hard HEAD

This will discard all your local changes. Then you shouldn't face any issues.

  •  Tags:  
  • git
  • Related