Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File permissions restore in Git

The following is the requirement:

  1. Create a file test.sql , set the permissions to –rwxr-xr-- i.e here the owner and groups has executable. Let's say the file is pushed to source control

  2. When I want to download the file back from source control the permissions should be retained as it is - –rwxr-xr--.

With Git when I pull the file from repository I see the permissions –rwxr-xr-x i.e the others have executable permissions which I wouldn't require.

The permissions should also be retained in development.

Could you please let me know how to retain the permissions when archiving.
I saw several answers in the forum but I couldn't get which one should be implemented,
git hooks? scripts?

like image 252
Satish Chandra Kajjam Avatar asked Feb 26 '26 08:02

Satish Chandra Kajjam


1 Answers

You can use this gist.

You store the permissions of your files and directories in a separate file named .git_cache_meta and no directly under git.

A full sample can be found here

Copied form the above post:

+# git bundle create mybundle.bdl master; git-cache-meta --store
+# scp mybundle.bdl .git_cache_meta machine2: #then on machine2:
+# git init; git pull mybundle.bdl master; git-cache-meta --apply
like image 116
CodeWizard Avatar answered Feb 28 '26 23:02

CodeWizard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!