1

I have a git repository with a config.properties by default where some user data has to be written. When I change the content, add *.properties to my .gitignore and then go for git status, it keeps appearing as modified content and would upload it. What can I do?

My .gitignore is listed below. I also tried to add the last line of .gitignore to git global ignore but it doesn't help:

 # .gitignore
/target/
/test-output/
.classpath
.project
*.properties
CKE
  • 1,533
  • 19
  • 18
  • 29
Chema Lopez
  • 375
  • 2
  • 3
  • 9

1 Answers1

4

Be aware that if the file you are trying to ignore is already tracked, it won't be ignored.

Check the documentation:

https://git-scm.com/docs/gitignore

Jules
  • 134
  • 1
  • 10
  • Yes, this is a possible solution, already tested. The problem with this, is that when I do "git rm --cached *.properties" and then go back to git status, it says that the file is deleted, and whenever I do a push of all changes, it will delete the file from the repository, and I want to keep that file. – Chema Lopez Sep 04 '18 at 06:54
  • I don't understand exactly what you are trying to do. If you want to modify your file but you want git to ignore the changes: git update-index --assume-unchanged /dirTo/yourFile. – Jules Sep 04 '18 at 09:01
  • I guess that might be a solution for now. I try to explain. I have a repository with a config.properties with some properties, but some of those have to be personal (User and password, for example). So I want everyone to have access to that file, but I dont want to update it, so, if I do "git rm --cached" and add the file to the .gitignore, it will detect that the file has been deleted and you want to delete it, but I dont want to delete it from the repository, I dont know if I explained right... If you dont understand its ok, I guess that solution may fit by now. Thank you – Chema Lopez Sep 05 '18 at 06:24
  • Then, if the solution fits now, please, mark the question as answered. Thank you. – Jules Sep 05 '18 at 15:44