0

My question may seem vague as I don't know much about git, but I'll try to be as clear as possible.

I have a repository on Github which I imported on Eclipse. As one could expect it, when I pulled on the command line the Eclipse project was refreshed (automatically, or manually, but it was clearly the same files) and when I modified the sources on Eclipse, it affected the git status.

I've had a huge build problem with Eclipse which led me to delete the project (not on the disk) and recreate it with Import existing projects into workspace. However, I noticed that the git status was unchanged when I edited the sources on Eclipse, so I pushed the changes on Eclipse, since it is imported as a git project. I thought it was ok, but I just discovered it was not the case. Here are two versions on the same file :

The version I want to priviledge : https://github.com/jxw1102/Projet-merou/blob/ffe65c33c57b5d547fe7b79c7345d0788629e882/ModelChecker/src/cfg/Model.scala

The older version : https://github.com/jxw1102/Projet-merou/blob/master/ModelChecker/src/cfg/Model.scala

Also see their respective history : https://github.com/jxw1102/Projet-merou/commits/ffe65c33c57b5d547fe7b79c7345d0788629e882/ModelChecker/src/cfg/Model.scala

and https://github.com/jxw1102/Projet-merou/commits/master/ModelChecker/src/cfg/Model.scala

Now I can date the issue and fix it quite easily, but could someone explain me how it is possible (where exactly the code has been pushed, if not to master), and how to change the Eclipse project so that it pushes on master ?

Dici
  • 25,226
  • 7
  • 41
  • 82
  • Last time I saw eclipse integration it was pretty terrible. It may be a lot less confusing to just do this stuff through the terminal. – Roman Mar 07 '15 at 03:33
  • Yep, but as I said when I edit my files, it does not change the local state of the repo, so I cannot commit anything, and I have no idea of where are the sources I'm editing in Eclipse as the workspace does not contain my project. – Dici Mar 07 '15 at 05:45
  • Deleting a project without deleting on disk, just removes it from what Eclipse knows of. No files are changed, so when you reimport you get back what you had. I would suggest creating a new workspace and a new clone. – Thorbjørn Ravn Andersen Mar 07 '15 at 12:07
  • @ThorbjørnRavnAndersen Yeah, I know, I just wanted to recreate the project to reinitialize its settings. I did a new clone and now it is fine, but I would like to understand this commit in terms of branch. I don't understand how the file can have two different histories – Dici Mar 07 '15 at 15:54
  • You essentially want to have "master" point somewhere else than it does now? Clone the project, delete the master branch (which does not remove any commits), checkout the commit you want master to point to, and create a new branch incidentially named "master" there. When you are satisfied (and NOT until then) "push -f" to github. – Thorbjørn Ravn Andersen Mar 07 '15 at 16:40
  • You could try running `git branch --contains ffe65c3` as described in [this question](http://stackoverflow.com/questions/1419623/how-to-list-branches-that-contain-a-given-commit) to see what branches your commit is in. Maybe that will help with figuring out how it got to where it did. – Roman Mar 08 '15 at 01:32
  • @R0MANARMY running this command, I got `master` (colored in green). Using the `-r` option, I got `origin/HEAD -> origin/master` and `origin/master` (both colored in red) – Dici Mar 08 '15 at 05:18

0 Answers0