Diego Ramirez
Diego Ramirez

Reputation: 65

Setting permission over files in git repo for many developers

I have a git repository which i am the owner and I have other dev that help me, I have an important file in the repo and only I should be able to edit or delete it.

Is there a way to limit the access to this file??

Have looked at the options but have not found the appropriate command.

Only myself should be able to edit or delete it.

Upvotes: 3

Views: 667

Answers (2)

Sebin Benjamin
Sebin Benjamin

Reputation: 1898

You could get something similar to file permissions by Configuring protected branches and Enabling required reviews for pull requests. This forces all code modifications to happen through Pull requests (PRs). Adding a review requirement to PRs makes sure that the changes are reviewed before merging. Read about pull requests and the related forking workflow.

Additionally, a CODEOWNERS file can also be added to define individuals or teams that are responsible for code in a repository. Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.

Note: As far I know, CODEOWNERS are applicable only in GitHub. PR's and review requirement configuration depend on the specific git hosting service you use.

Upvotes: 1

LMG
LMG

Reputation: 1370

Assuming all you need is to limit edit/delete (read "changes"), a pull request policy (read "code review") is a good practice.

Here is a link using GitHub on how to put this in place: Enabling required reviews for pull requests

Upvotes: 1

Related Questions