Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Git Error: How do I remove files saying “old mode 100644 new mode 100755” from unstaged changes in Git?

How I got this error:
I had to take a pull in my project directory
I tried to take the pull by running the below commands
cd <My Project Directory>
sudo git pull


The outcome of the above command was:

root@ip-172-31-20-213:/opt/lampp/htdocs/sp-hospital-ms# sudo git pull
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 5), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From bitbucket.org:surgeryplanet/sp-hospital-ms
6c3214b..bd047fe master -> origin/master
Updating 6c3214b..bd047fe
error: Your local changes to the following files would be overwritten by merge:
app/Http/Controllers/PassportApi/QuoteManagementController.php

Please commit your changes or stash them before you merge.
Aborting
root@ip-172-31-20-213:/opt/lampp/htdocs/sp-hospital-ms# sudo git pull -f
Updating 6c3214b..bd047fe
error: Your local changes to the following files would be overwritten by merge:
app/Http/Controllers/PassportApi/QuoteManagementController.php
Please commit your changes or stash them before you merge.
Aborting
root@ip-172-31-20-213:/opt/lampp/htdocs/sp-hospital-ms#

As you can see it is telling me that I have some local changes in a file with name QuoteManagementController.php. In fact there was no real local change to that file

Then I tried to check the difference by issuing the command show below:
git diff --unified=0 app /Http/Controllers/PassportApi/QuoteManagementController.php

The output was:
diff --git a/app/Http/Controllers/PassportApi/QuoteManagementController.php b/ap p/Http/Controllers/PassportApi/QuoteManagementController.php
old mode 100644
new mode 100755

Solution:
Run the command given below in your project’s home directory:
git config core.filemode false
Then
sudo git pull (only if you need to take the pull)


Chetan