2

I have worked on an Android project for which I've used versioning locally and on GitHub. Now I decided to use Eclipse' Refactor > Rename... to give the project a more suitable name. To my surprise, Eclipse silently removed all connections between the project and the git repo.

Now what...? I cannot even commit locally, let alone push to github...

I'm far from fully versed in git and I had some problems getting Eclipse and git agree with each other (http://stackoverflow.com/questions/8756006/eclipse-egit-push-to-remote-menu-choice-is-grayed-out), but at least it worked (but I cannot remember exactly how I got it to work), and I can see all my commits pushed to the hub, but how can I restore the connection so I don't mess up the versioning?

OppfinnarJocke
  • 1,038
  • 2
  • 9
  • 21
  • When I in Eclipse go to Project > Properties > Git, I get a dialog saying "The currently displayed page contains invalid values". I click OK, I get a page listing "Git directory": "Working directory:", "Branch:" and "Current state:", but no entries for any of those. This is where I should be able to put in the pointer to my remote git repo, right? – OppfinnarJocke Jan 17 '12 at 20:53
  • Do you still have a `.git` somewhere in your renamed project? – VonC Jan 17 '12 at 20:55
  • Yes, .git is where I'd expect it to be, in the renamed project folder. I looked into the files there, but they don't tell me much... and apparently they don't tell Eclipse much either :-) – OppfinnarJocke Jan 17 '12 at 21:07
  • OK... right-clicking in the "Git Repositories" tab, Eclipse allows me to "Paste Repository Path or URI", and if I do that a "Clone Git Repository" dialog opens. Is this something I want to do? Will it overwrite or merge...? – OppfinnarJocke Jan 17 '12 at 21:22
  • I don't think cloning would help. Maybe trying to delete the project from the workspace (the project alone, not its content), and then reimport it would hep. – VonC Jan 17 '12 at 21:38
  • @VonC Heureka! This seems to have worked. At least it looks like Eclipse recognized the old .git repo, and everything looks like it's been set back the way it was. But.. do I dare push to the remote...? I'll sleep on it :) Thanks for the help, much appreciated. – OppfinnarJocke Jan 17 '12 at 21:56
  • A push should work. I have made an answer below to summarize those comments so far. – VonC Jan 17 '12 at 21:59

1 Answers1

5

To summarize the comments above, one workaround, when the project within an Eclipse workspace doesn't behave properly, would be to:

  • delete the project from said workspace (the project only, not its content on the disk)
  • re-import that same project into the workspace.

Eclipse should detect again the .git directory within that project and consider it under version control.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • will this maintain the commits (version history) ? or is starting over with a blank slate? – ycomp Feb 23 '12 at 16:24
  • I would like to just rename my project folder in the filesystem.. will this technique described above in this Answer work for me? – ycomp Feb 23 '12 at 16:25
  • @ycomp: yes, this process would have no side-effect on the history managed by the git repo. The `.git` project doesn't care about the name of its parent directory (which would be named after the new name of your project). – VonC Feb 23 '12 at 16:33