I have a database.properties file that has
password = something
Therefore, whenever I have to test something, I will have to change this line to my local password. Everyone in the team will have their own local password.
I think I will need to do one of the following:
Every time I commit, I should not add database.properties to the index (I do not want to ignore this file), but when there are too many files it is easy to skip this file.
Revert the changes before committing, but most of the time I forget for this.
Creating a profile may be a way to achieve this, but it will even have similar problems, such as database.properties .
I checked. Can git ignore a specific line? and How to tell git to ignore individual lines, i.e. gitignore for specific lines of code .
From temporarily ignoring files I see what we can do
git update-index
but I have to do it every time.
All the above links were asked / written up to 3-4 years. So I just want to know if there is a better way to ignore just one line.
EDIT
After @VonC's answer, I tried adding a filter to .git/info/.gitattribute
{directory_path}/database.properties filter=password
And I added smudge and clean scripts as:
git config --global filter.password.smudge ~/smudge.sh git config --global filter.password.clean ~/clean.sh
(When I run ~/smudge.sh and ~/clean.sh , it correctly replaces the password= something . Therefore, the scripts are correct.)
But when I add / commit database.properties , the database.properties file does not seem to be affected. (I assume ~/clean.sh should run when I add it to the index)
What am I doing wrong?
source share