DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • When Airflow Tasks Get Stuck in Queued: A Real-World Debugging Story
  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Git Tags vs AWS Tags: A Tag-Tastic Showdown!
  • GitOps Software Development Principles – And the Benefits for the Entire Organization

Trending

  • Data Lake vs. Warehouse vs. Lakehouse vs. Mart: Choosing the Right Architecture for Your Business
  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 1
  • Operational Principles, Architecture, Benefits, and Limitations of Artificial Intelligence Large Language Models
  • Endpoint Security Controls: Designing a Secure Endpoint Architecture, Part 2
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Tracking File Permissions in Git

Tracking File Permissions in Git

Take a look at how you can change the permission tracking settings in git so it doesn't create a new file for every single change.

By 
Sudip Bhandari user avatar
Sudip Bhandari
·
Aug. 07, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
16.0K Views

Join the DZone community and get the full member experience.

Join For Free

 Although I have been extensively using git for quite some time now, I never happened to come across this situation where you change the permission of the file which is tracked by git. Yes, by default, git is configured to track the changes in file permission mode, too.

Just to experiment with the idea, I created a dummy repo and "touched" an empty file. The initial default permission was 775.

I added the file to staging and changed the permission bit to 777. Git diffing at this point yields an output of following sort:

old mode 100644
new mode 100755


That perfectly reflects the fact that for this particular file, octal permission codes have changed and git has detected that as a change.

You can commit this changed file and it will be tracked by git for the change in permission. You can roll back to the previous commit and the previous permissions will be restored.

However, if you don’t want git to detect file permission changes, which is most likely the case as you probably don’t want to scroll through all the files to find out which ones were actually edited/changed, you can disable the default config by issuing:


git config core.filemode false


Here’s a link to a Stack Overflow question discussing about this issue. To quote one of the comments to understand why git is designed that way:

"This means that git thinks that it can correctly set the executable bit on checked out files, but when it attempts to do so it doesn’t work (or at least not in a way that it can read). When it then reads back the status of those files it looks like the executable bit has been deliberately unset. Setting core.filemode to false tells git to ignore any executable bit changes on the filesystem so it won’t view this as a change. If you do need to stage an executable bit change it does mean that you have to manually do  git update-index --chmod=(+|-)x <path> 

Git

Published at DZone with permission of Sudip Bhandari, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • When Airflow Tasks Get Stuck in Queued: A Real-World Debugging Story
  • Terraform Drift Detection at Scale: How to Catch Configuration Drift Early
  • Git Tags vs AWS Tags: A Tag-Tastic Showdown!
  • GitOps Software Development Principles – And the Benefits for the Entire Organization

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!