Git's approach to conflicts caused by file permissions modification and ignoring file permissions

Source: Internet
Author: User

When publishing the project to the line, many times need to modify the file permissions, if the use of GIT version management software to publish, then the next time you update the online file will prompt file conflicts. Obviously the document has not changed, why conflict? It turns out that git also counts file permissions as part of the file differences. The following author has made a simple example to illustrate this situation.

1. Modify the permissions of the repository file, and then use diff to view the changes.

$ chmod 777 pack.php$ git diff pack.php

Git file Permissions Modification example

You can see that git also includes file permissions in version management.

2, in another Place clone this repository, modify the pack.php file, and then submit.

3. Update the content below the original repository.

$ git pull

Conflicts caused by Git file permissions modification

You can see a prompt conflict.

Workaround:

In Git, you can add a configuration that ignores file permissions, as follows:

$ git config core.filemode false

This sets the Ignore file permission. View the following configuration:

$ cat. Git/config

Git ignores the configuration of file permissions

Then update the code is OK.

Summarize:

I personally understand that version management more attention to the content of the file, more curious about why git file permissions in version management, it is estimated that some scenarios are needed. The author has tried to change the file owner and all the groups not included in version management. And how does git handle file permissions under Windows?


Git's approach to conflicts caused by file permissions modification and ignoring file permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.