Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent successive commit on specific file on git?

Tags:

git

I have some configuration files to commit on GIT with default parameters. Users can pull these files and can modify them on their local copy but they must not commit/push.

How can I achieve a similar result? the file gitignore doesn't fit my need because file must be commit only the first time

like image 598
dafi Avatar asked Aug 16 '10 08:08

dafi


People also ask

How do I prevent git commit--no-verify?

Prevent it on the developer side with a pre-commit hook. Note that git commit --no-verify will bypass this safety mechanism. The code below blocks any changes at all to files dir/key1.json and key2.json.

How to show list files exclude from git commit?

Simply copy command and paste in terminal and it will display list files exclude from git commit, make sure run this command on your project path

How to prevent commit into Dev and master branch in Git?

Here you need to create a small bash script to prevent the commit into Dev and Master Branch. First we need to get the branch name where commit is getting performed. This can be done by using git rev-parse --abbrev-ref HEAD command and the resultant can be stored in a variable called branch in this case.

How to avoid sensitive data being tracked in Git?

Add all sensitive files to .gitignore to make sure git wonʼt track them. Donʼt try to hide the mistake. Other collaborators and you in a month will appreciate the explanation of what happened and what this commit fixes. To avoid a situation like this in the future, here are a few tips on storing sensitive data:


1 Answers

Could you use git's "assume unchanged" function? If this is set, git always assumes that the file in question has not been modified. This means that git status, git commit etc. will skip the file. Please note that the user can still push a new version of the file into your remote repo but it will take some extra work to do that.

Here's a question where the usage of "assume unchanged" was discussed more thoroughly.

like image 106
Mikael Koskinen Avatar answered Oct 14 '22 04:10

Mikael Koskinen