Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started 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)


DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.