Reputation: 3611
git pull origin master
gives me the following messages:
Updating da4fe55..2fda2d1
error: Your local changes to the following files would be overwritten by merge:
app/Http/Controllers/AppointmentsController.php
resources/assets/js/userschedule.js
resources/views/home.blade.php
Please, commit your changes or stash them before you can merge.
Aborting
Read other stackoverflow questions/answers and tried the commands below, nothing worked (don't understand why they didn't help):
git checkout origin/master -f
git checkout master -f
git stash (and git pull after)
git reset HEAD --hard
git clean -fd
Isn't there a way to completely ignore these files? Not sure what to try next.
This is a project I cloned from bitbucket, and I didn't change any of those local files. The project in bitbucket was updated so I was looking to update my local files using a git pull
.
After testing git add .
git status
# Changes to be committed:
#
# modified: public/js/userschedule.js
#
# Unmerged paths:
# (use "git add <file>..." to mark resolution)
#
# both modified: app/Http/Controllers/AppointmentsController.php
# both modified: resources/assets/js/userschedule.js
# both modified: resources/views/home.blade.php
Upvotes: 1
Views: 1248
Reputation: 36700
As you mentioned, nothing should be changed, so it's probably a new line issue. This should resolve it:
git reset --hard origin/master
It will reset your local branch and makes its equal to the master branch on origin. All local changes (even committed) will be lost.
Upvotes: 1
Reputation: 1875
This error is normal to happen. If someone else edited and pushed, you have to merge theirs commit. So, you can do two things:
Merge commits
Normally, you want to add your changes to the repository. So, you commit your changes, and merge:
git add .
git commit -m "Foo commit"
git pull origin master
Now, you just have to merge it (if there are conflicts)
Ignore your changes
If you don't want to keep your changes, just remove it, and pull:
git checkout .
git pull origin master
Be careful: With this, you will lose what you changed at the code!
Upvotes: 0