How do I set up Eclipse/EGit with GitHub? - eclipse

I've never used Git before and would like to learn.
I have a private repository with GitHub.
I've installed the EGit plugin for Eclipse.
I have a workspace where I do my work, generally: ~/Documents/workspace.
I am able to add my GitHub repository and download it, but in doing so it creates ~/MyRepository.
When I create a project, do I need to point it to ~/MyRepository?
Also, how come when I make an edit and I say push to upstream it says up to date?

Make sure your refs for pushing are correct. This tutorial is pretty great, right from the documentation:
http://wiki.eclipse.org/EGit/User_Guide#GitHub_Tutorial
You can clone directly from GitHub, you choose where you clone that repository. And when you import that repository to Eclipse, you choose what refspec to push into upstream.
Click on the Git Repository workspace view, and make sure your remote refs are valid. Make sure you are pointing to the right local branch and pushing to the correct remote branch.

In Eclipse, go to Help -> Install New Software -> Add -> Name: any name like egit; Location: http://download.eclipse.org/egit/updates -> Okay. Now Search for egit in Work with and select all the check boxes and press Next till finish.
File -> Import -> search Git and select "Projects from Git" -> Clone URI.
In the URI, paste the HTTPS URL of the repository (the one with .git extension). -> Next ->It will show all the branches "Next" -> Local Destination "Next" -> "Import as a general project" -> Next till finish.
You can refer to this Youtube tutorial: https://www.youtube.com/watch?v=ptK9-CNms98

Install Mylyn connector for GitHub from this update site, it provides great integration: you can directly import your repositories using Import > Projects from Git > GitHub. You can set the default repository folder in Preferences > Git.

Related

Eclipse Git (egit) pull and push to upstream option not available some times.?

Right click on Project -> Team -> push and pull not available(EGIT)
Eclipse pull and push to upstream option not available some times.?
i am able to see commit every time but push ,pull,remote are missing some times
How to make appear them always
Basically your eclipse is disconnected with git.
Right click on project -> Team -> share Project -> Select Repository type as git -> Next -> chose your project and finish.
For me this disappeared as well, while the .git/config is unchanged and good.
Refresh did not help.
But Eclipse restart did the trick.
The options disappear sometime if the EGIT is not able to find the path from which it should Fetch, Pull and Push.
Check if the origin is deleted.
Goto the GIT Repositories View
See for the Remotes -> origin
If the Push and Pull in origin are deleted. You will have to add the URI by right click on the origin, add origin and configuring the Push and Fetch URI.
I hope this will be helpful.
Yes, this is a frequent annoyance. If Refresh doesn't work, I use "Close Project" followed by opening it again.

Restore deleted Eclipse Project

I wanted to make a new git repository in eclipse and when I was deleting the old one, unluckily the whole project has been deletet from the workspace!
Is there any way to restore the project?
I would appreciate your answer!!!
If you have another repository with your work (like a central git server,another developer, another computer or something like that) you can just clone your repository back from that:
File -> Import -> Projects from Git -> URI ->
Type in your server/the other developers repo and complete the wizard.
And here is the reason why you lost your work:
In order to make git work, egit moves all the project files into the repository (which is only a special directory). Therefore, if you delete the repository, you also delete all the files in it, containing your whole project.
For the future:
To move your repository, just move it to another position using a normal file explorer. After that, tell eclipse about that by removing the repository from the repositories view (NOT deleting it):
In the Repositories View: Right-click on the repository ->
Remove from Repositories View
Then add the repository in its new location:
In the Repositories View: Upper right corner:
Add existing Git Repository to this view
A couple of years late, but in case anyone else sees this: You can right click on the project folder and select "Restore From Local History...".
With any luck you should be able to restore the lost files from there.

Git, SVN and Eclipse workflow

I am trying to adopt the following workflow:
git svn clone a svn repository through command line (egit doesn't support git-svn)
Open the project in eclipse with egit since I rather use egit to branch, merge, commit etc...
When i'm ready commit the changes back, I use use git svn dcommit to commit back to svn
I am having trouble with step number 2, don't understand how to import a git project, eclipse tells me i can't import it to use the same directory it's currently in because another project with the same name is already there. this is confusing.
Anyone knows how to do this ?
Also would like to hear other workflow examples that uses egit and git svn. I am aware that it is better to do it all through command line, however, I am trying to ease the move to git for fellow developers in my team, who are not used to command line interface etc...
I've worked briefly with the egit plugin (I actually recently stopped using it and just use msysgit as my Git guiclient and run it separately from Eclipse). I find Eclipse very busy as is and adding this plugin slows it down (for me at least).
What I did when setting up an already cloned project in Eclipse:
In Eclipse. File -> Import -> Existing Project into Workspace
Select root directory of project. Do NOT check copy projects into workspace. Click finish.
After project has been imported. Right click on project, go to Team -> Share Project
Select Git as a repo type, click next
Check use or create repo in parent folder of project. Since you already cloned the project it will be tracked with git. When you check this option it will show the project, the path, and the repo (.git).
Click finish and you will be all set.
I think you'd better use SubGit instead of git-svn.
SubGit works on a server side. It synchronizes all the modification between Subversion and Git repositories automatically on every incoming modification from either side.
From the client perspective SubGit enabled repository is a usual Git repository, so you may pull from and push to it. Please refer to SubGit documentation or SubGit vs. git-svn comparison for more details.

How to set up Mercurial on Snow Leopard with Eclipse

I'm using Eclipse with C++ plugins on my macbook, trying some practice projects to improve my skills. I'd also like to test out Mercurial and get a taste of DVCS. Unfortunately, Eclipse + Mercurial + OSX seems to be a rare enough combination that there isn't a lot of helpful documentation out there.
What I've done so far:
Installed Mercurial SCM
Installed the HgEclipse plugin
Installed GnuPG
Set path to GnuPG and hg executables in Eclipse preferences > Team > Mercurial
I know I can turn a directory into an hg repository by navigating to that directory in terminal and using
hg init
and then I can add files with
hg add
hg commit
This should give me an hg repo with my files in it. So far, so good...but now I begin to falter.
How do I get HgEclipse pointed to my repo? My synchronize view has a Mercurial option, but when I select it, the Next button is grayed out, and the Finish button doesn't do anything...
Ideally, I would like to set up two local repositories, one personal and one "team" repo, so I can really evaluate Hg as this seems to be the popular configuration. Does HgEclipse only support commits to a single repo, or can it commit to the local repo and push to the "team" repo?
Any other suggestions from DVCS vets on how best to set up my environment?
To point eclipse at your local repo there are two main ways.
File -> Import -> Mercurial -> Clone (Starting a new Project from a repo)
(right click Project) -> Team -> Share Project -> Mercurial
(see How to turn on Mercurial in existing Eclipse project ?)
When you are up and running you can Push/Pull to another repository via the Team push/pull menu item.
(right click Project) -> Team -> Pull ...
(right click Project) -> Team -> Push ...
Ran through the setup steps again, following this excellent guide and everything is now working. I had a little trouble getting my brain around the fact that the eclipse workspace is itself a repository. With that set up, I was able to commit changes and push to another repository very easily.

How do I create a git repository over an eclipse project or vice versa?

I have a git repository that is just a directory tree (/myprogram/src/com/mycompany/test) with some source files. I wish to create an eclipse project around this repository. Both orders of create project in eclipse and git clone <url> <myprogram> from the command line give me a "folder already exists" error from whatever tool I use last. I could move the files manually to merge them, but it feels messy and I'm not 100% confident I know which files to touch.
How is this supposed to be done properly?
You could do it by selecting Import -> Existing Projects into Workspace, select the directory containing your project (the parent of myprgram), and check the checkbox next to your project (myprogram).
To have Git support in Eclipse, install eGit and then right-click your project, select Team -> Share Project -> Git, expand the triangle to select the existing repository and click Finish. This should give you Git annotations on your project.
Another option might be to just select Import -> Git -> Git Repository (after eGit is installed) and import your repository (but I've never done that with a local repository). See also the eGit user guide.
To resolve this I just ended up copying the git repository into a newly created project, but upon revisiting the issue I found a link here that suggests something slightly more elegant (but functionally similar).
After creating a new project, use Import -> Filesystem and Select All. In my case, my repository already had a proper /src/com/... directory structure which merged nicely into the one set up by the new eclipse project.