Skip to main content
Image
Git

Ignore file permission changes with Git

Git, the popular version control system, offers a number of options to configure how files are handled, including core.fileMode.

This command tells Git to ignore file permissions when performing operations like git add, git commitand git pull. In other words: Git will not take into account whether a file is executable, readable or modifiable, and will treat it as a normal file that is not versioned.

What is it for?

Use core.fileModecan be useful in several situations:

  • Avoid permission conflicts: on computers with different operating systems or permission settings, this command can avoid conflicts when syncing files.
  • Simplify your workflow: if file permissions do not need to be considered for development, this setup can simplify the commits and pulls process.
  • Improve tool support: some development tools may have problems with files with special permissions. Disablingcore.fileModemay fix these issues.

Implications to consider

Although it can be useful, it is important to keep in mind some implications:

  • Information loss: If file permissions are important to the project's operation, disabling them could cause errors or security issues.
  • Inconsistency with the production environment: If file permissions are different in the production environment, problems could arise when deploying the code.

Recommendations:

  • Carefully evaluate the need to use core.fileMode false.
  • Document the configuration in the project README.
  • Use configuration per project or repository, not globally.
  • Test the configuration in a development environment before deploying it to production.

How to use

Simply move from the console to a project versioned with git and run the following command:

git config core.fileMode false

Once the command is launched, git will ignore any permission changes on versioned files for the project in which you are located.

Related to Git...

  • git config: allows you to configure Git configuration variables
  • core.fileMode: configuration variable that controls how Git handles file permissions.
  • git add: adds files to the Git index for later commit.
  • git commit: creates a new commit with the changes to the index.
  • git pull: downloads changes from the remote repository and merges them with the local copy.
Tags

Join the Drupal Sapiens Community

Save content that interests you, connect with others in the community, contribute to win prizes and much more.

Login or create an account here

Latest posts

Featured

Last news