Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Working Directory to Eclipse Workspace

I have been building my maven project(s) within my spring tool suite work space and have now decided that I need to get busy with some version control.

I have gone for GIT and have used the command line client to produce a local repository.

So, I have a local repo - which is ready to implements version control and a workspace with a load of files.

I am using the GIT plugin for Eclipse. See the image below.

enter image description here

How am I able to somehow synchronise my workspace with my git working directory so I can start to stage and commit indexes to Github?

Many thanks

//** EDIT **//

Okay - having found this blog

I realized it is a simple project->team->share project option in the Eclipse Project Context Menu.

Thanks

like image 413
totalcruise Avatar asked Jan 21 '12 13:01

totalcruise


People also ask

How do I link a GitHub repository to Eclipse?

Copy the GitHub URL of the repository to the clipboard. Open Eclipse and choose Import –> Projects from Git (with smart import) Choose the Clone URI option in the Git import wizard and click Next. Confirm the URI, Host and Repository path parameters and click Next.

How do I pull a Git repository in Eclipse?

Open the Eclipse Import wizard (e.g. File => Import), select Git => Projects from Git and click Next. Select “URI” and click next. Now you will have to enter the repository's location and connection data. Entering the URI will automatically fill some fields.

Can we connect Git with Eclipse?

The Eclipse IDE provides support for the Git version control system. You can easily perform the necessary Git commands like staging, commit, merge, pull and push via the Eclipse IDE. Git is pre-installed in Eclipse IDE. If git is not installed by default, go to Help > Eclipse Marketplace and install git explicitly.


1 Answers

This blog post (from Lucas Piva Rocha Corrêa) details the step you need to follow to share your local git project on GitHub;

  • that includes the "Team Share" you found
  • but it also mentions the ssh settings you need to get right in order to be able to push to an https GitHub address.

Configuring Eclipse

  • Go to Windows -> Preferences and filter SSH. Select SSH2 on the left tab (should be under General -> Network connections).
  • Check that SSH2 home is set to /home/<yourusername>/.ssh and id_rsa is in Private Keys.
  • On Key Management tab, click on Load Existing Key... and select your id_rsa (private) key under ~/.ssh/id_rsa. If your key has a non-empty passphrase, eclipse will not be able to load it, even if you provide the correct password.
  • Now, just save it in the same location you loaded it from, confirm empty passphrase, overwrite it, apply and click ok.

Pushing your project to your github repo

Final step is to push your project to your remote repository on github.

  • Finally, select the project you want to push to your created repository, right click it, go to Team -> Share Project... and select git.
  • Select your project, click on Create Repository and Finish. Now you should be able to commit and update changes to your local git repository.
  • To push it to your remote GitHub repo, right click your project, select Team -> Remote -> Push...
  • Fill the URI with your project SSH address, which is shown when you enter your repository page on GitHub.
  • Select ssh protocol, user is git and empty password.
  • Cross your fingers, hit next. If it doesn't work for some reason at this point, try restarting Eclipse (it worked for me after restart).
  • Select Source Ref and Destination Ref (basically the branch), click on Add Spec and Finish on the next screen.
  • Hopefully everything goes well.
like image 121
VonC Avatar answered Sep 24 '22 11:09

VonC