Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)
edited by

My .gitignore file seems to be being ignored by Git - could the .gitignore file be corrupt? Which file format, locale or culture does Git expect?

My .gitignore:

# This is a comment

debug.log

nbproject/

The output from git status:

# On branch master

# Your branch is ahead of 'origin/master' by 1 commit.

#

# Untracked files:

#   (use "git add <file>..." to include in what will be committed)

#

#       debug.log

#       nbproject/

nothing added to commit but untracked files present (use "git add" to track)

I would like debug.log and nbproject/ not to appear in the untracked files list.

Where should I start looking to fix this?

1 Answer

0 votes
by (50.2k points)
edited by

As your files are not tracked yet, so git is not aware of your files so .gitignore is ignored  by git for that first add the files to .gitignore

For adding to .gitignore run the following commands 

git rm -r --cached .

git add .

git commit -m "fixed untracked files"

 Note: commit your changes or else it will be lost.

For more information please go through the following tutorial to get more info about git:

.gitignore is ignored by Git
Intellipaat-community

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...