I'm trying to add config file for my database where you can keep your account and password for local use. The problem is that when i make change to that file it is being tracked. What i need is some way to add this file to .gitignore, the file to stay in the repository and any further changes to not get tracked. I know about git update-index --assume-unchanged <file>
but I dont want that change to be local. Everyone who clones the repo should be able to set his db acc and pass and this file shouldnt be tracked for further commits. Any ideas?
Asked
Active
Viewed 61 times
2

Todor
- 51
- 3
-
Note that you should not use `--assume-unchanged` anyway as explained [here](https://stackoverflow.com/a/13631525/1615903) - use `--skip-worktree` instead. – 1615903 Jul 18 '17 at 04:49
1 Answers
2
The best way to do this would be to have a file in your repository, say user_pass.txt.example
. Then add user_pass.txt
to the .gitignore
file. When users clone the repository, they should copy user_pass.txt.example
to user_pass.txt
and edit that file.

houtanb
- 3,852
- 20
- 21
-
I thought about that workaround but I'm just wondering if there is a straight forward way to deal with this problem. – Todor Jul 17 '17 at 13:08
-
@Todor I don't think you have other choices, the idea is to make git track a "template" of file which is supposed to contain server information. So the template shouldn't contain sensitive information. In the other hand, git should NOT track server information. – smarber Jul 17 '17 at 14:12
-
@Todor another idea would be to have a 2-line install script that clones the repository and then runs the `--assume-unchanged` command. Yet another idea would be to distribute a template file that users would use in their git clone call that would do the same thing.... Unfortunately, there's no `git clone` hook that can do it for you. – houtanb Jul 18 '17 at 09:52