Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore not working: files that should be ignored still get committed

Tags:

git

I'm trying to create a new git repository from existing folder. I've created a .gitignore file in the root of the folder. But if I say

git add * git commit git push 

files that should be ignored still get committed to the remote repository. I'm on Windows. Also I've bought a license for SmartGIT. It also seems to ignore .gitignore. I have to manually select which new files to commit.

like image 237
John Grey Avatar asked May 24 '10 22:05

John Grey


People also ask

Why is .gitignore not ignoring my files?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them. Igal S.

Do Gitignore files get committed?

gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

Should .gitignore be ignored?

The . gitignore file's purpose is to prevent everyone who collaborates on a project from accidentally commiting some common files in a project, such as generated cache files. Therefore you should not ignore .

Does Gitignore ignore tracked files?

gitignore file prevents future untracked files from being added to the git index. In other words, any files that are currently tracked will still be tracked by git.


1 Answers

Try "git add ." instead.

Also, it works for me (on Linux):

 $ git init $ echo foo > .gitignore $ echo foo > foo $ echo bar > bar $ git add -v * The following paths are ignored by one of your .gitignore files: foo Use -f if you really want to add them. fatal: no files added 
like image 115
Jakub Narębski Avatar answered Sep 20 '22 03:09

Jakub Narębski