sun station sun station - 2 months ago 15
Git Question

Git ignore accidentally commited file

I'm working on a project with 4 member of team, everyone have different files config, and we're already using

git update-index --assume-unchanged to/the/file
but the newcomer hasn't noticed to use update-index to the config files and accidentally pushed the file to the repo as in:

application/config/database.php


And we're working with branches, while we're pulling the file on master it got no warning/something. But the database config file has been changed, and everytime we tried to change branches, this following files always needed to checked out before we change branch.

Is it any method we could ignore this file as if anyone has been changed it? So it wouldn't prompt us to checking it out before we change branch.

Thank you in advance.

Answer
  1. Remove the file from git : git rm --cached file
  2. Commit and push the change
  3. Add path file in .gitignore file on root folder of your repo. This will protect you fron new user to commit the file
  4. Commit and push the .gitignorefile

Documentation : gitignore

Comments