Why is git still trying to add the classpath files? - eclipse

I am working on a windows computer with cygwin using git with eclipse...
git keeps trying to add the following files
modified: EJB/.classpath
modified: WAR/.classpath
but if you look in my .gitignore it looks like this..
Flex/src/generated/
work/
logs/
build/
EJB/classes/
WAR/WebRoot/WEB-INF/classes/
.classpath
EJB/.classpath
com.genuitec.eclipse.persistence.jpa.prefs
WAR/.classpath
WAR/.classpath
EJB/.classpath
what else can I do or try?

I think you have added those .classpath files to git earlier, and git is already tracking them, so adding them to .gitignore is not sufficient.
You need to stop tracking it in your repo. Try
git rm -r --cached EJB/.classpath WAR/.classpath
git commit -m "untracking .classpath files"
And after this, gitignore will ignore the changes to them.

Related

How can I ignore any changes in a particular folder from Git

I want to exclude the changes in all files in a folder Api\Bin*.* and Core\obj*.* into GitHub merging. I dont want to consider that folder while merging the changes. How can I do that Please advise. I have added the following line of code in ignored file from Repository->Setting->Ignored files , but not working . When compile the program , still obj and bin folder files is showed in changes of GitHub
You can add a line in gitingore files following ways
logs/
These lines will ignore the logs folder. Even you can use patterns.
If those files are already tracked, no amount of .gitignore would work.
You need to remove them first (from the Git index, not from your disk)
git rm --cached -r API/bin/
git rm --cached -r Core/obj/
Then check (no commit needed) if you see them in GitHub Desktop.
You can also see if your .gitignore rules apply with:
git check-ignore -v -- Core/obj/<anObjFile>

Git ignore not ignoring directories

I'm trying to ignore obj, bin, debug type files/directories from my Visual studio project. I've followed the advice here:
ignoring any 'bin' directory on a git project
This is not working.
I've pasted the entire git ignore here:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
This is not working.
I've tried all sorts of things...
bin/
obj/
*bin/
*obj/
/bin/
/obj/
packages
MyProject/MyProject/obj/
MyProject/MyProject/bin/Debug/
MyProject/MyProject/obj/*
MyProject/MyProject/bin/Debug/*
The directories and their files are still being included when I run a git add. The .gitignore file is added and commited. What am I doing wrong???
EDIT: The files I'm trying to ignore aren't already being tracked. When I run a "git status" there are no pending changes. "nothing to commit, working tree clean". Then I run my VS program which modifies the files in those folders. Then I run another git status and all of the files show up as "modified"...
EDIT2: Does it matter if the files already exist? They are not being tracked but DO exist in the folder structure. When when I run the program they show up again as "modified". Then I have to run a "git checkout ." to remove them all. Then the cycle repeats...
If your file was already been tracked and committed before adding in .gitignore, it won't ignore it. You would require to remove it from index to stop tracking
For file
git rm --cached <file need to remove>
For Folders
git rm -r --cached <folder>
So that would be an issue in your case since Jenkins is still able to see the file in the repo
Hi look at the edit part ,
If you already have any folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won't stop tracking paths that are already being tracked just because they now match a new .gitignore pattern. Execute a folder remove (rm) from index only (--cached) recursivelly (-r).
git rm -r --cached yourfolder
Based on your "Edit 2" above, it sounds like you don't think these have been previously committed, but in reality, they have been. If it shows up as "modified", the git is recognizing the file has changed from the last version it has checked in. If the file was not already committed previously then it would show up as Untracked.
When you are running git checkout on those files, you are telling git to revert those files back to the last version that was checked into git.

restore.dg is not fitlered by .gitignore

In my newest .NET Core ASP.MVC project I seem to be unable to ignore the restore.dg file. By default, the Visual Studio .gitignore file is set to ignore the whole .vs/ folder, in which the file is located. As this did not work, I tried several methods how to get rid of the file, yet unsuccessfully.
# Visual Studio 2015 cache/options directory
.vs/
restore.dg
*.dg
.vs/*
Could somebody help me?
Remove it from the cache.
git rm --cached .vs/restore.dg
git commit -m "Remove restore.dg from the cache"
See also: How to make Git "forget" about a file that was tracked but is now in .gitignore?
This might happen after you have already committed this file into the repository. If this is the case you have to remove it using git rm --cached <filename> command and commit this change to the repository. After that it will disappear from git status and will never bother you again.

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

Git overriding .project file in eclipse

This is is a simple question. When I switch between branches my eclipse files get deleted in my project because they are not in my repository. .gitignore only works when checking in, not when switching branches. How can I keep my .project files in my project filed while using git?
Thanks
If a .project file was committed to the repository before it was added to .gitignore, it won't be ignored. You need to remove it from the repository. Since you probably want to keep it in your working tree, try this:
git rm --cached .project