gitignore does not ignore .DS_Store files - gitignore

why gitignore does not ignore .DS_Store files ?
this is my .gitignore file
#Directory based project format
.idea
# Ignore Mac DS_Store files
**/.DS_Store
#node modules for grunt
node_modules
#files generated with grunt
src/app.js
this works for node modules and src/app.js perfect, but does not ignore DS_Store.
Can anybody tell me why ?

Use this command to delete a file from the repo, but not delete the file itself:
git rm --cached <file>
After you removed it, you can ignore it using .gitignore.

Related

Why doesn't this ignore my files recursively?

In my project's root directory there are directories like 'tools':
tools/evaluate/test/
tools/evaluate2
Under test, there are some .py and .csv files. I want to ignore all files except .py, so in my .gitignore, I have this entry:
!tools/**/*.py
I want to recursively ignore all non-python files under tools. What's wrong with that?
if the files you are trying to ignore have been already committed, you need to remove them from the staging area as well, that's done by:
git rm --cached !tools/**/*.py
check the status:
git status
add the files you want to delete to .gitignore i assume manually, i don't know of an automatic way, then finally:
git add .gitignore
git commit -m "Remove unused files"
Two parts are needed here:
# Recursively ignore everything in tools that has an extension:
**/tools/**/*.*
# Except .py files recursively in tools:
!tools/**/*.py

ignoring subdirectories using gitignore and ignore files in general

Say I want to ignore node_modules, but also node_modules for subdirectories:
project/
node_modules
bar/
node_modules
foo/
node_modules
baz/
node_modules
.gitignore
what do I need to put in my .gitignore file too ignore all node_modules folders?
By default, git uses patterns from .gitignore to match content in sub-folders recursively. So, putting the following content into .gitignore is enough.
node_modules/
If your folder node_modules has been added into the repo already. You need to untrack them.
git rm --cached node_modules

.gitignore in subdirectory is getting ignored

I have created a .gitignore file in a subdirectory.
/errors/company/.gitignore
I need it to ignore the file /errors/company/seiten/start/content.phtml.
Content of .gitignore:
seiten/start/content.phtml
But it does still show the file if execute git status. Why?
If you have already commited the .gitignore file, and you still see that file in git status, it is because the file was being tracked from before. You should do the following:
git rm --cached /errors/company/seiten/start/content.phtml
That should do the trick.
PD: I would leave just one .gitignore in the root directory with all the ignored paths and files.

Git commit shows changed files like metadata although they are in gitignore file

The information on the commits on GitHub says there are thousands of additions and deletions in files such as metadata even though the metadata is in the gitignore file.
This is how looks like my gitignore file:
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders
.springBeans
You probably added certain files to .gitignore after they had already been tracked by git. If this is the case, you need to tell git to untrack the file:
git rm --cached <file>

gitignore misses some binary files (DLLs & PEs)

I use the latest version of Github Desktop. My repo consist of a rather large C# solution with many sub-directories and projects. I'd like to ignore all R#-cache files and compiled binaries using the .gitignore file which resides in the root directory of the local repo directory. There are no other gitignore's anywhere in this repo and none in any parent directories. My current gitignore is this:
*.suo
*.user
_ReSharper.*
bin
obj
packages
*.cache
*.pdb
*.dll
*.exe
*.xml
When I made my changes, recompiled and tested everything, I open Github Desktop. It catches almost all files that should be ignored, only some .dlls, .pdbs and .exes are not ignored and always show up as changed:
Now, there are way more binary files in this repo. Only the specific ones in the screengrab are missed.
Is this fixable, and/or can the gitignore be altered to catch all files that it should catch?
Here's what I tried:
Removed and re-cloned the repository
Removed and manually re-created the gitignore
Right-click->Ignore by file extension from within the GitHub Desktop client. This does not work, worse, it creates duplicate masks in the gitignore
Checked for conflicting gitignore's in directories accessible by Github Desktop
Maybe you have files that were already being tracked by git before you modified the .gitignore? Those files (at least in git 1.9.1) aren't ignored when added to a .gitignore.
For example, I created a "test" directory at the root file one of my repos and put a file in it:
mkdir test
echo "abc" > test/x.txt
I added, committed and pushed it. Then I edited .gitignore at the root and added this line:
x.txt
I also made an edit to test/x.txt AND added a new file:
echo "123" >> test/x.txt
mkdir test2
echo "xyz" > test2/x.txt
Now when I run "git status" I see:
modified: .gitignore
modified: test/x.txt
So test2/x.txt is being properly ignored, but test/x.txt is still being tracked.
To force the file to be ignored, you can delete it, add & commit the deletion together with the .gitignore change, then restore the file.