Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitignore settings included in commit

I'm trying to commit the right files in git, but having problems configuring my gitignore properly. I followed the instructions here to create the gitignore file (django project):

# File types #
##############
*.pyc
*.swo
*.swp
*.swn

# Directories #
###############
logs/

# Specific files #
##################
projectname/settings.py

# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon
Thumbs.db
*~

The problem is that settings.py is getting included in the commit:

Admin$ git add .
Admin$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   projectname/settings.py

How can I ignore settings in my gitignore?

like image 390
Nick B Avatar asked Dec 07 '22 04:12

Nick B


1 Answers

It looks like you already have settings.py under version control by git. In this case git will continue to track the file - no matter what you write in .gitignore.

You have to explicitly tell git to forget about settings.py:

  1. Add it to .gitignore (As you did)
  2. Remove the file from git without deleting the file: git rm --cached projectname/settings.py
  3. Commit the change: git commit -m "remove settings.py"

Afterwards git will ignore the file. But be aware that versions which are already commited will stay in your repository.

like image 126
Scolytus Avatar answered Dec 11 '22 08:12

Scolytus