jbolt
jbolt

Reputation: 688

Git Eclipse import source folder into project

I have a bit of an issue that I can't seem to find a solution to.

I had a project in eclipse that I was working in. I have a remote git repo in which all the source files are backed up to (but it doesn't seem to be the entire project). My project got deleted in eclipse but I had previously had a backup of the entire directory that I had zipped up and emailed to myself a while back which contains the entire project including external libraries etc that I need for the project.

I can import the zipped project into eclipse but obviously the source directory is out of date. I need to be able to pull from my existing repo all the changes I made to my source files. I was able to use the Restore From Local History from the context menu in eclipse which brought in all my changes up until my last push.

Is there a way to re-link this newly create project with my existing repo so all my original commits are available to the new project? Or is there a way to get my source files from my repo into the newly created project. I'm not sure how to proceed and I don't want to make any further changes until I get this resolved.

Any help would be greatly appreciated.

Upvotes: 0

Views: 1244

Answers (1)

25A0
25A0

Reputation: 341

Depending on how you restored the other files, you might run into merge conflicts once you pull from your remote repository. Make sure to make a backup first.

Eclipse:

In the context menu of your Eclipse project, you should see the entries

Team -> Remote -> Configure Fetch from Upstream / Configure Push to Upstream

There you can configure where to fetch from, and where to push to, respectively. Once you have configured the URI to your remote repo, you might want to use the Dry-Run button to check that it is linked correctly.

Command line:

You can also use the command line to organize your remote repositories. Navigate to your project and run

git remote

to get a list of your remote repositories. If that list is empty, you can use

git remote add <remote-name> <your-remote-repo-url>

to add a remote repository. So, e.g.

git remote add origin https://github.com/yourUsername/yourRepo

Then you should be able to pull from your remote as usual.


Alternatively, you could follow this guide to import the remote repository as a new project. This will bring back the source code in its current state in the remote repository. But you mentioned that the remote repo does not contain the whole project. So you would probably have to add all files manually from your restored project that were not tracked by the git repository.

Upvotes: 1

Related Questions