11

I'm using EGit with Eclipse Juno. I worked with a local repository and the world was good. Even adding a GitHub repository seemed to be fine. I added it to my local repository under "Remotes", so I can easily push commits to github. But after a while, I noticed that no new files are added to the repository, even if I'm commiting changes. They just are not under version control. They have no symbol, which should mean they are ignored. This is my .ignore

.gwt
gwt-unitC
ache
Versandanzeige_Web_proto.war
Versandanzeige_Web.war
war/ajax
war/WEB-INF/classes
war/WEB-INF/deploy
www-test
  • The files are in src, so not even close.
  • The new files don't appear in the Commit-Dialog, even when checking "show untracked files". They don't appear in the Staging-Window.
  • RK -> Team -> "Add to index" doesn't help.
  • The files have the same right and are owned by the same user
  • They definetly dont show up at github

Any ideas how to fix that? Any additional information needed?

Update: There are no errors in the error log.

I do have (HEAD) next to my newest branch.

More details: I got my trunk T, beginning at T0. At T1, there is a branch A, which has changes to T1. At T2, there is another branch, B. It has no changes to T2. The strange thing: it is not indicated in History view. The master branch is also missing. I can still switch to them. When I do git reflog, there are no entries before or including T2, just everything afterwards.
I removed the branches without commits: enter image description here enter image description here enter image description here

The new files are still shown as ignored:
enter image description here

Output from command line:

$ git branch -a: 
* master 
maven 

$ git status 
# On branch master nothing to commit (working directory clean)

About the detached HEAD proposel: I didn't do what is described in the article, checking out an old state and work from that. And I can't see any undone commits.

Sorry for my bad english, I didn't use it for a while. Please ask for clarification, if I write something hard to understand.

Update: I could add a file in another folder (/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar).

Markus
  • 1,598
  • 2
  • 13
  • 32
  • Any exceptions in your Error Log view? – Karen Butzke Oct 09 '12 at 23:32
  • Aren't you in a detached head state? http://eclipsesource.com/blogs/2011/05/29/life-lesson-be-mindful-of-a-detached-head/ – VonC Oct 10 '12 at 06:54
  • @KarenButzke: There were no errors I couldn connect to the problem and there didn't were any new errors when I tried to add the files to the index – Markus Oct 10 '12 at 11:40
  • @VonC: I'm not sure. I do have a (HEAD). I rebased my branch to be (HEAD), so I'm working an HEAD right now. I still can't commit the new files. One strange thing though: I'm missing branches in EGit. They are showing up on github, but not in EGit (see update). – Markus Oct 10 '12 at 11:43
  • Look for your branches as illustrated in the article I mention: do you have an active branch? Working in HEAD isn't enough: HEAD must be next to a branch name. – VonC Oct 10 '12 at 11:53
  • @VonC: Alright, here is something odd: I have one branch that is not showing up in History View (let's call it A). When I switch to it, I have no HEAD, only ORIG_HEAD. When I switch to my other branch, B, I have (HEAD) next to B. But A doesn't even have changes, it is just an older version of the same branch as B, where I want to make changes later. Could this be a separated head? – Markus Oct 10 '12 at 12:00
  • @VonC: I actually want to add the files to the HEAD branch. Another strange thing: the master-branch is also not showing up. – Markus Oct 10 '12 at 12:05
  • Does this mean I have a detached head? But how do I fix it? There are no commits on this branch. Or I understood something wrong. – Markus Oct 10 '12 at 12:16
  • Mmmm a couple of screen shots might help here ;) Anyway, HEAD isn't a branch: see http://stackoverflow.com/questions/964876/head-and-orig-head-in-git/964927#964927, and detached HEAD is described here: http://stackoverflow.com/questions/3965676/why-did-git-detach-my-head/3965714#3965714 – VonC Oct 10 '12 at 12:43
  • Also, what does a `git branch -a` and a `git status` return? (using the CLI (Command-Line Interface) of git) – VonC Oct 10 '12 at 12:44
  • I removed the branches that had no changes. `git branch -a: * master maven git status # On branch master nothing to commit (working directory clean)` – Markus Oct 10 '12 at 13:07
  • Ok, so we know you aren't in a DETACHED HEAD mode. Those ignored files are in the same directory? (Ie, are they symlinks or actual files?) – VonC Oct 10 '12 at 13:24
  • All actual files, all same rights and owned by my current user. – Markus Oct 10 '12 at 13:27

2 Answers2

37

Alright, I found the error. For some reason I don't really know, there was another .gitignore file ABOVE my Project folder (in repository folder), where my COMPLETE project folder was included. I really don't know how that happened. Of course, this file didn't show up in Eclipse. I tried to add the files on the command line, but gut the error message "File is in .gitignore file". After deleting that file, it worked find. Sorry for the trouble.

Asanke
  • 551
  • 1
  • 11
  • 32
Markus
  • 1,598
  • 2
  • 13
  • 32
2

Sometimes EGit does not work properly and add to index does not work. In that kind of situations you can go to the root folder of your project (where .git folder is placed) with a file explorer, right click on an empty area inside the folder, select "git bash". This will open the git console for you. Now type "git add path_to_file". This will add the file to the git system for indexing. Now go and refresh your project in eclipse and you will see it is added to the index. This can be used wile resolving conflicts inside eclipse because adding to the index indicates "mark as merged" to the git system by re-adding the merged file.

Also sometimes the "Remove from index" does not work in eclipse, you can do the same thing in that kind of situation: this time write "git remove --cached -f path_to_file". Here do not forget to add "--cached" because otherwise your file will be deleted. -f stands for "force" to force the command. For any folder (directory) to remove from index type "git remove --cached -r -f path_to_folder".

Bahadir Tasdemir
  • 10,325
  • 4
  • 49
  • 61