1

In my case, l have a database config file database.php and a hook to deploy the project.

l need to modify the database.php to connect my local database, but l don't want to push it to remote, because it will affect the dev env by hooking.

l tried to use git rm --cached -r database.php to untracked the file, but it will delete this file at remote git server. so my dev server will also delete this file.

then, dev server BOOM.

l also tried git update-index --assume-unchanged database.php, but it is not suitable my case so well.

afraid.jpg
  • 965
  • 2
  • 14
  • 31

1 Answers1

2

This would work for you since it will skip tracking the changes for this file then onwards.

git update-index --skip-worktree <file>

This little article and the stackoverflow answer here will help you.

Gimhani
  • 1,318
  • 13
  • 23
  • so cool! but l still have a question. this project is a multi-person project. so, do they(other developers) also need execute this command? – afraid.jpg Sep 06 '18 at 03:21
  • i believe this only affects the local repository. so others too will need to do so. – Gimhani Sep 06 '18 at 04:03
  • @afraid.jpg have you tried updating the .gitignore once the file is already tracked.based on https://stackoverflow.com/q/35451148/4848659 , it too will be a solution. – Gimhani Sep 06 '18 at 04:04