Reputation: 463
I am using git for the first time and I am trying to make a commit. I want to ignore all .project and .settings files so I went to my .gitignore
file and added .project
, .settings
and saved. When I did that the .settings
file doesn't appear anymore, however, I still see my .project file when I do git -status
. Also, why is the .xml
and java
file in a different section that the .jar
files:
Upvotes: 0
Views: 354
Reputation: 521103
Your git status
output is showing you two types of files:
These are files which Git is tracking, and these files have been modified since the previous commit. But, the changes have not yet been staged. Unless you stage the changes using git add
, they will not be committed. Here is how you would stage the change to the web.xml
file:
git add path/to/web.xml
Assuming you really just started working, then the most likely explanation for why the .project
is showing up as being tracked by Git is that you somehow added it. To fix this, you can try using:
git rm --cached .project
This removes the .project
file from being tracked by Git. It would also remove it from the remote repository, but since you just started working and haven't pushed yet, this is a moot point.
These are files which Git is completely ignoring. From Git's point of view, these files are not there. I can see that you have a number of JAR files listed as untracked, which is probably a good thing, since in general it is a bad idea to add binary files, especially dependencies, to your Git repository. Should you see a source file listed as untracked, you could also run git add
to add that file to Git.
The reason it is generally considered bad practice to add binaries to a Git repository is that Git doesn't handle diffs of binaries very well. Suppose you add a 1MB JAR file. Each time it changes, which could be fairly often if you are doing some open source stuff, a diff has to be stored for that binary. But, Git often will interpret the diff as being deleting the old file and replacing it with the entire contents of the new file. In other words, Git basically versions the entire binary for each change. Over time, this can cause your repository to become large and bloated, and it can be difficult to get rid of those binaries from your history. So, unless absolutely necessary, avoid storing binaries in your Git repository.
Upvotes: 1