Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Unable to add subproject to commit(Project added to repository cannot be added to index when committing)
Unable to add subproject to commit [message #1835488] Fri, 04 December 2020 15:38 Go to next message
Jonathan Pierre is currently offline Jonathan PierreFriend
Messages: 2
Registered: December 2020
Junior Member
For a while, I've had a java project in my Eclipse workspace that is connected to a Git repository owned/controlled by my organization (hosted by Bitbucket). Then I created another java project and tried to include that with the branch the first project was a part of (it was months ago, so I don't remember how I linked it).

The problem I've been having is when I try to commit and push the second project. Changes to the first project are handled correctly and are included when pushed to the repo. The second project, however, appears in the list of unstaged changes (one listing for the whole project) and when I try to add it to the index, nothing happens; it stays in the list of unstaged changes. However, the project display shows that it is part of the branch I try to push it to.

When I try to change something in one of the files in the second project, there is no visible indication that a change has been made (no right arrow at the start of the file name). When I downloaded the last commit of the branch from the repo, the first project folder was fine and contained the contents of the project, but the second project folder was just empty. When I look at the commit in which I first committed the second project I see the addition of it as a subproject (though the second project is not within the first, but on the same level as it) , but nothing else.

Is this a bug or is there something I've been doing wrong?

The Eclipse version is 2019-06 (4.12.0)
Re: Unable to add subproject to commit [message #1835509 is a reply to message #1835488] Sat, 05 December 2020 10:00 Go to previous messageGo to next message
Aaron Hawley is currently offline Aaron HawleyFriend
Messages: 2
Registered: June 2019
Junior Member
Are using git submodules? Or do you just have two remotes configured in your repository (e.g. "origin" and "upstream")?
Re: Unable to add subproject to commit [message #1835519 is a reply to message #1835488] Sat, 05 December 2020 16:35 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 373
Registered: August 2016
Senior Member
I suspect this is the clue:
Jonathan Pierre wrote on Fri, 04 December 2020 15:38
... (it was months ago, so I don't remember how I linked it).

What do mean by "linked it"? Where on the disk is your second project? If it is not in the git working tree, git will not commit it, and won't be aware of changes you make in it.

I'd expect to see what you describe if you had used a symbolic link. (Single entry in unstaged changes for the whole project.) The next bit ("when I try to add it to the index, nothing happens; it stays in the list of unstaged changes") is a bit of a mystery, unless you're on Windows, where JGit cannot handle "symbolic links". (JGit is the Java git library used in Eclipse. Windows doesn't really have symbolic links; I think for directories they have something called "junctions", and JGit definitely cannot handle those.)

Generally, you'd create the second project by choosing New...->Project in the context menu of Eclipse's package or project explorer. Once the project is set up, you'd then choose Team...->Share Project... and share it with the git repository you want it to be in. That operation will move the project's files and directories inside the git working tree directory. (In Eclipse, the project will still appear unchanged, unless you examine the on-disk paths via Properties.)

Then commit.
Re: Unable to add subproject to commit [message #1837411 is a reply to message #1835519] Fri, 29 January 2021 14:34 Go to previous messageGo to next message
Jonathan Pierre is currently offline Jonathan PierreFriend
Messages: 2
Registered: December 2020
Junior Member
Hello,

The project I'm trying to push to the remote is in the same directory on my disk as another project I've pushed successfully (that should be the working tree?).

Based on your description, it does sound like the icon under "Unstaged changes" is a symbolic link (one icon representing the whole project). I am indeed using Windows, so that may be the problem.

Should I try using Team > Disconnect on the project I'm trying to push and then try the Team > Share Project process?
Re: Unable to add subproject to commit [message #1837437 is a reply to message #1837411] Fri, 29 January 2021 22:37 Go to previous message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 373
Registered: August 2016
Senior Member
Team->Disconnect won't move the project, so you'll likely end up in the same situation. I'm not equipped to track this down on Windows (I have no Windows machine available, only a super-slow VM; working normally on OS X or Linux). To really figure this out you'd need someone to examine this is situ on your machine.

My next best suggestion would be:

  • zip the whole project directory, put this zip file aside.
  • Then delete the project in Eclipse, then delete the whole project directory in Windows Explorer.
  • Unzip the previously created zip archive somewhere, say, in some subfolder of your home directory.
  • In Eclipse, choose "Import..."->"Import existing projects". Choose the just unzipped folder, and "copy into workspace".
  • Once the project is in Eclipse again, do the Team->Share Project process.

If it really was some symbolic link or junction problem, it should be gone then, and the directory should be a real directory.

If that also doesn't help, find someone who knows git and who can sit down with you to figure this out directly on the machine.
Previous Topic:What is the difference in the INDEX file format compared to the Git bash?
Next Topic:Obtain blob size efficiently
Goto Forum:
  


Current Time: Sat Jun 19 18:51:52 GMT 2021

Powered by FUDForum. Page generated in 0.02083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top