Integrating Eclipse and GitHub - eclipse

I am in need of help in trying to setup Eclipse so that I can push my code onto my GitHub account. I've searched online and the tutorials I have found are either outdated or don't work for me.
I already have a project on Eclipse. How would I put that code onto GitHub? Would someone please add detailed instructions please. Any help is appreciated.
EDIT
As soon as I posted this question, and fiddling around with the settings I managed to get it to work! What a coincidence...
The only problem I have now is how do I set it up so that when I commit it will only select the files in the project folder? Right now it is showing all 600 files in the Package Explorer.

Alright, there are several ways of doing this. I found this to be the easiest way:
First, set up SSH2 configurations. Go to Windows->Preferences->General->Network Connections->SSH2->Key Management and Generate RSA Key. Save Key
Copy that key. You will need to go to your GitHub account settings and add the new SSH key to your account.
Now, you need to install eGit:
Next, you want to add the Git Repositories view:
Create a new Git Repository. I have already created a repository called Java. I will refer to that repo for the rest of the explanation.
After you create your repository, it should show up in the Git Repositories view. Now to add your project to the repository, right click on your project and select Team->Share Project.
Select the repository you just created. You can also use CTRL+ to select multiple projects and place them in one repository.
Now go back to your Git Repositories view. Go to Remotes . Right click and select Create Remote.
Select Change... and enter the SSH link for your Repository on GitHub.
For connection, select SSH. Then press Finish.
For Rev-mapping, select Advanced....
For Source Ref select refs/heads/master. And then press Add Spec, then select Save specifications in 'origin' configuration. Then press finish.
That's pretty much it. You can commit changes by right clicking your project - >Team->Commit...`
Push new commits to GitHub:
This is a really good explanation on how to set up Eclipse pull requests.
The current branch is not configured for pull No value for key branch.master.merge found in configuration

Related

Git hub project _ Learning)

I am working on a simple project to learn github. After I worked on my project in eclipse on my local computer, I pushed my project to github for other teammates. A second member of my team pulled this project from github and pushed back to github after making some changes. Now this morning I want to pull this updated project from github to my local machine (eclipse) so I can work on this updated project.
How can I pull this updated project from github to direct into eclipse on my local computer .
I am tried to do:
"git clone http://github.com/testproject/gitDemo.git" but it is not directly going to eclipse. If I save this project on my machine and then try to import into eclipse I got error message, "can not import, there is already one project exist with same name".
I did not see pull option in eclipse under:
Right click on project - team - Pull
Any suggestions??
Thank you in advance for all your help
I'll make one point that I'm not certain you do NOT understand, but as I often see this misunderstood, I'll point it out.
You should separate the notion of "git repository" and "project". When you clone a git repository from github (or bitbucket, or some central repository), you should store it in a directory tree outside of your Eclipse workspace. You then should right-click on the repository and select "Import..." to create a project from the contents of that repository.
Related to that, you should look for the "Pull" operation on the repository entry, not the project. I recommend to display the Git Repositories view on the left side, below the Package/Project Explorer, and make sure that you attempt all git operations in that view, instead of the Package Explorer view.
The only detail from your original post that I can address is the error about already having a project with that name. That error message is not ambiguous at all. You already had a project with that name. I have no idea whether that project was a copy of the repository that you had somehow already imported, or whether it's an empty project, or what. You don't provide any information about that.

Project is already on GitHub

I tried to share my Java project via IntelliJ to GitHub. In this case I choose VSC/Import into Version Control/Share Project on GitHub and go through few windows. But at one where I should provide repository name and its description I cancel the operation. But the repository was shared... So I removed it via GitHub webpage. I tried share it one more time via IntelliJ, but I get Project is already on GitHub info. How can I solve this situation?
Go to your project physical location and find .git folder(hidden, right click open in new window, if you have problems on mac). You might need figure out how to show hidden folders/files on your OS.
Find file "config"
Delete section(s) [remote "name"]
Try to share again
Enjoy )
Then manage remotes
then delete here

Eclipse Kepler: How to share an existing project to an existing remote Git repo?

I currently Eclipse Kepler on my new computer with EGit. And I have a particular project on it, not linked to any repository.
Now there is a remote Git repository (with all the account and password information at hand) someone else created for me and I want to push this project onto it. Since I never used Git on eclipse before, I figured it may be somehow similar to my limited experience with CVS - so I tried: right click -> team -> share project -> Git (I read somewhere that I should select the "remote" option, but there is no such option besides "share project" and "Apply Patch"), but it only shows the local clone of the Git repository, and if I tried to add the project to it it tells me that "cannot move project to target location as location overlaps..." So now I am stuck and not sure what to do, can anyone help me find the right direction?
Thanks in advance.

How to properly use EGit with Eclipse

The only way I seem to be able to get use git in eclipse is to create a non-git project then turn that into a repository. This ends up moving the project out of the eclipse workspace on the file system. I then have to delete the project(it's still in the git repository), then import a git repository after creating a branch and clone it to get it back into the eclipse workspace.
Is there a simpler way?
I simply want to create project that is really a clone from a local repository. Essentially I have two copies on my HD but I can commit the eclipse project to the git repository. Unfortunately there has to be a better way?
To answer this question involves three steps.
Create a external (remote) repository
Share the project in a way that it remains in the workspace
Connect the project repository to the remote repository
Create a Remote Repository on Your Local Machine
Switch to the Git perspective. Click on Create a new Git Repository.
When a dialog appears select a directory where you would like your remote
repository to be. This is were your project will be pushed to. You will also
want to select the Create as a bare repository option.
That's it for this step. You should now have this repository in your EGit
repositories list.
Sharing Project within the Workspace
There are two ways to share a project so that it remains in your workspace.
1. Make the project directory a repository
2. Make the whole workspace directory a repository
The Project as a Repository
The first option option is not recommended by the Eclipse team. This issue is
described in more detail at Why is not recommended to have an Eclipse project folder as a Git repository?.
The basics of the issue are twofold:
You can't have more than one project per repository
If some thing happens to your workspace you'll lose your repository too
Issue 1 isn't solved here. Issue 2 can be solved by connecting to a remote
repository as show later.
To share the project as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click Use or create repository in parent folder of project
Select the project from the list
Click on the Create Repository button
Click the Finish button
Next you'll want to connect your newly created repository to the remote repository.
That's covered below.
The Workspace as Repository
The second options allows multiple projects to be added to your repository.
In fact any new project you create will automatically added to the repository.
Automatically adding projects can cause some issues.
One issue is that, if there are changes in multiple projects, staging
those changes can take a bit of wading through. Using a Tree presentation when
staging can simplify things.
Another more serious issue occurs when importing a git clone of a project into
the workspace. This importing will create nested repositories. Nested
repositories can cause problems
according to this post.
By default Eclipse doesn't import the git clone of the project into the workspace.
To share the workspace as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click on the Create button
Select your workspace as your Repository directory
Click the Finish button
Once your repository is created you may want to do a little house keeping. I suggest
adding the RemoteSystemsTempFiles project to the .gitignore file. Note: the
.metadata file is added automatically by Eclipse.
You can ignore the RemoteSystemsTempFiles by:
Switching to the EGit perspecitive
Selecting the workspace repository from the list of repositories
Select the Git Staging tab
Click on the View Menu button on the right side the the tabs toolbar
Select Presentation -> Tree menu (folders are easier to ignore form the tree view)
Right click on the RemoteSystemsTempFiles project
Select the Ignore Folder menu
Ignore other projects in the same way
Connecting to the Remote Repository
The last stage is connecting the workspace repository to the remote repository
we created earlier. Once you've switched to the EGit perspective:
Expand your workspace respository
Right click on the Remote node in the tree
Select the Create remote... menu
Leave the remote name as origin
Select Configure fetch
Press Ok
Click on the Change... button
Click on the Local File button
Select the bare repository that you created in the first section
Click Finish
Click Save and Fetch and then Ok
You can then stage, commit and push changes in your projects and workspace.
When you first commit and push EGit will push the default branch master
to the remote and configure pulling this branch from remote repository.
Follwing the User Guide, you would need to create the .git repo within your current project path:
If the .git path is within the current project path, there is no reason EGit moves your files anywhere else.

Eclipse/Egit, Push to Remote menu choice is grayed out

I created a repository on GitHub. I set up a local git repository using Eclipse and Egit.
With Team > Remote > Push. I managed to push the local repo to the one on GitHub.
Now I expected to be able to use the Team > Push to Upstream (as well as fetch from upstream) as a one-click push (and pull/fetch), but this menu choice is not available (grayed out). I have to use Team > Remote > Push to each time manually fill in the info (ctrl+space helps).
Following this, I created a remote configuration and pushed from the repositories view, and I can see the remote GitHub repository listed under Remotes but still the Team > Push to Upstream command is grayed out in the menu.
Could someone please give me a hint as to what I have may done wrong?
Here's what I did and this worked fine:
Right click your project, choose Team→Show in Repositories View. You will switch perspectives and be in the Git Repositories tab.
Right-click "Remotes" and choose "Create Remote". For "Remote name", enter "origin". Click OK.
Click Change. Enter your information as you did during your initial push. Click Save.
You should now be able to push by merely right-clicking on your project, then Team→Push to Upstream.
Because the remote was added under the project in question, each project can have its own upstream origin and they will not interfere (whereas the Window > Preferences solution is a global setting).
Based on your description of what you did, it appears you attempted this - but possibly did not use the name "origin" for the remote, which is absolutely necessary. I stumbled across this solution by pure chance.
I had this problem and thankfully found a way to re-enable the "Push to Upstream" option.
Go to Window > Preferences > Team > Git > Configuration.
Select the Repository Settings tab and then the repository that represents your project.
Click "New Entry..."
The key is remote.origin.url
The value is the url you copy from github. It's usually offered predominantly on whichever site you register with.
Perhaps there is a neater way of achieving the same thing. Once I reached this far I stopped looking because it works now.
You need to have the following type of configuration in that repository's .git/config file:
[branch "master"]
remote = origin
The remote setting can be any of your remotes or just a value of .
You can edit the repository's config by selecting the Properties menu item from the context menu for the repository in the Git Repositories view.
I came here searching for solution to solve similar problem with bitbucket - although none of the two highest votes answer didn't work for me, it proved that I had option "Put branch...", when I tried to do this, it says "Non fast-forward", but when I successfully made "pull", I was able to push to upstream.
Maybe it will help someone :)
This post might be a little old, but I had the same issue with one of my repos the following information from this link worked for me: Adding a remote to an existing git repo
The part i want to highlight from that article is the following:
[branch "master"]
remote = origin
merge = refs/heads/master
When I made the change in the .git/config and refreshed eclipse the "push to upstream" link worked for me. Keep in mind, I am assuming that you have a remote configured in your Git perspective for your remote repository.
In my case all git commit/push operations are inactive. I fixed the issue by placing the repository folder under git directory.