James
James

Reputation: 53

Creating a new root directory in an Eclipse project under version control

I'm working on a group project for my software engineering course, and my professor has indicated that I set up the directory structure incorrectly on Github. I'd like to correct the issue now to avoid a grade penalty, but I'm very new to using Git. Basically we have a structure that is as follows on Github.

src
--main
----java
------Source Files
--test
-----java
------Test Files
Various Ivy/Ant build files
.classpath
.gitignore
.git
.project
README.md

I need to create a new directory called CodeComp that will contain the directory structure above except for the README.md, which should be on the same level as the CodeComp directory.

Since our grade is dependent on the commit history, this would need to be preserved. Is there an easy way to do this or are we better off just taking the small deduction on the final project grade?

UPDATE: In case anyone else has to do this in the future:

  1. Go to the folder holding the project and create the new directory.
  2. Move all files needed into the new directory except .* files. Refresh Eclipse.
  3. Commit and Push the directory changes to the repo regardless of Eclipse errors.
  4. Manually delete the .classpath, .gitignore, and .project files from the repository.
  5. Back-up your .classpath and .gitignore files. Delete your local copy of the repo and re-clone it.
  6. Import the Git project and choose to put the project files in your newly created directory.
  7. Copy the .classpath and .gitignore you backed up into the new project directory. Push the changes.

Upvotes: 2

Views: 1133

Answers (1)

Lucas Fraser
Lucas Fraser

Reputation: 38

In theory you should be able to use a standard file browser to move everything but your .git and Readme file into your new sub-folder and then commit that.

The git history will still there but it may see it as two separate files, one that has been deleted and one that is just created. In my experience Git doesn't really like moving files.

In any case, you commit history will still be in the repository, it will just be 2 separate sections from when you moved the files.

But, hey... It may pay to show that move anyway. I know for sure that I was moving files all around when I first learnt about version control. It's all learning.

EDIT: You can test this by committing the change locally and checking the history before you push it upstream to Github.

Upvotes: 1

Related Questions