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

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>

Related

gitignore > some ignored files still added to the repository

I don't understand why ignored files are still added to the repository. Are there some circumstances when files which are in the .gitignore list, can be still added to the repository
I added directory to the .gitignore before I did anything with the project (project is clean, no trucked or untracked files). Then I built the project. During the build process some files were modified. When the build was done, most of the modified files were ignored, but some were added to the repository. I don't understand this git's selectivity.
Usually, files are added to the index when modified if they were tracked before the .gitignore referenced them.
Try:
git rm --cached -r biz/modules/rest-apis/docs/refAddress
Then control that all files are ignored, by selecting one which was added before:
git check-ignore -v -- biz/modules/rest-apis/docs/refAddress/GET_1.0_v4_addresses.json
You should see a .gitignore rule (no output means: the file is not ignored).

.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.

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.

gitignore does not ignore .DS_Store files

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.

How to ignore IDE settings on Git?

I have below Git information and I would like to ignore settings of my IDE (Eclipse).
modified: myproject/.classpath
modified: myproject/.project
modified: myproject/.settings/com.google.gdt.eclipse.core.prefs
modified: myproject/.settings/org.eclipse.core.resources.prefs
modified: myproject/.settings/org.eclipse.jdt.core.prefs
modified: myproject/.settings/org.eclipse.wst.common.component
modified: myproject/.settings/org.eclipse.wst.common.project.facet.core.xml
modified: myproject/.settings/org.eclipse.wst.validation.prefs
I tried the below statements in my .gitignore file, but it doesn't work for these settings:
.project
.classpath
.settings
*.project
*.classpath
*.settings
/.project
/.classpath
/.settings
.project/
.classpath/
.settings/
*.project/
*.classpath/
*.settings/
I am using Mac OS X and I also added global gitignore file with these settings git config --global core.excludesfile '~/.gitignore', but I'm still getting the above Git update messages when I check with git status. What am I wrong?
If those elements were already committed, you need to remove them first:
git rm --cached .project
git rm --cached .classpath
git rm --cached -r .settings
The --cached option allows them to stay in the working tree, while being recorded for deletion.
Once deleted, they will be ignored.
Once committed, the next changes will be ignored.
A simple .gitignore in myproject/ folder is enough:
.project
.classpath
.settings/
Note the / for .setting folder: that will ignore everything in it.
Following is my .gitignore config for a java web project:
*.class
*.swp
*.cache
*~
bin/**/*
target/**/*
build/**/*
gen/**/*
# tmp source folder
tmp/**/*
# js plugin
WebContent/js_plugin/lib/**/*
After git 1.8.2, If you want to ignore a folder named abc in any folder or subfolder, use following:
**/abc/**/*
So, I suggest you upgrade your git, if it's too old.
By the way, in my opinion, if team is using the same IDE, you should sync the .classpath things to git, ofcause, this is base on you have convention to name your jdk / tomcat / ... things like this. So that,once a jar is added via maven, all people get it after pull.
But, if you commit eclipse config, when push, make sure that change is useful, if not, don't commit, e.g. 2 source folder just change their line orders, in this case you can git checkout -- xxx, to ignore that change, so that won't effect other people.
It worked for me yeah but removing files from cache would be more helpful
#IDE files .gradle .idea idea-module-files *.iml com.springsource.sts.config.flow.prefs org.sonar.ide.eclipse.core.prefs
org.springframework.ide.eclipse.beans.core.prefs
org.springframework.ide.eclipse.core.prefs
.springBeans
eclipsebin
org.eclipse.jdt.core.prefs
org.eclipse.jdt.ui.prefs
NPM packages
**/node_modules
Compiled class file
*.class
Test classes
**/testclasses