Pulling a project from GitHub with EGit - eclipse

I've setup a private GitHub account to make it easier for me to work on the same project on both my desktop and my laptop when I'm not at home. The project was originally on my laptop, so I configured EGit to push and commit to my private repo. That worked successfully, and now I can see my project when I log onto GitHub. I'm now trying to pull that project onto my desktop. I did the same configurations , and in the Git Repository View within Eclipse I can see Remotes->origin-> the Push/Fetch streams. I tried to fetch, and that placed an origin/master branch under git\branches\Remote Tracking. But I can't seem to do anything with it.
I'm not sure what to do next, or if I made a mistake somewhere?

Now just right click it and Create branch.... This will make a local branch that will track this remote branch. When you push Eclipse should automatically configure everything so that origin/master will get updated.
Check out the local branch to start working.
UPDATE:
To import the project from working copy select the following:
If you have checked in your configuration files (.project, .classpath etc) you will get a list of all available projects in the repo to import to workspace. If not you will need to import them manually.

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.

Eclipse, Egit, Github: remove pushed project folder

I have successfully created a git hub repository, a local master, committed the initial changes and pushed them to github.
Unfortunately the project folder from Eclipse ends up in the repository. For example:
<username>/<gitrepositoryname>/<eclipse project folder>/<project files & README>
when for most people it looks like:
<username>/<gitrepositoryname>/<project files & README>
I created a new local master after I found this tutorial Push eclipse project to GitHub with EGit
but now I am running into push problems such as "HEAD rejected - non-fast-forward" when using the new local master.
Can some please help me to correct this locally/remotely? Is there a way to switch local master branches so that I can sync the correct one with githib?
Thanks in advance.
It's pretty simple to fix:
Go to the "workspace" where you keep <eclipse project folder>
Make sure to delete the .git folder there
Tell git to force push the changes. (Checkbox) (It's usually not good to force git to do something, because you could loose commits/data BUT here, we really want to overwrite the old repository with the new one.)
Your changes should be up immediately. Next time you push, please make sure, the force push checkbox is disabled again

Confusing Eclipse and Github interactions

We are trying to use Eclipse and github on a project, and it is proving to be a real burden because we do not understand how it works. It is difficult to formulate a single question, but let's start with one case:
We have a project in Eclipse that is on github. Several developers are sharing the archive. We learn that we want to create a Java EE project rather than a Java project. We do not want to change the name of the project. How can this be done?
Further, not knowing this, we tried to change the name from ProjNamet to ProjName2.
When creating a project on git, Eclipse creates it in a local directory:
c:/Users/username/git
In order to push that project out to github, we executed:
git remote add origin github.com/author/projname
git push origin master
As far as we can see, the project appears to be successfully pushed out to github.
In addition to source code, there is:
.project
.gitignore (which just ignores the build directory)
.classpath
.settings
But when I right click on the repository and try to import projects from it to my computer, Eclipse failed
deleting the directory, and clicking on File->import.. and importing from the repository works.
I do not see what the difference is between the one that worked and the one that did not.
Try this:
git remote add origin github.com/author/projname
git push origin master

Git pull successfully but not shown in eclipse

I have a project imported from git repository to eclipse. The thing is, when others made changes from their parts (kind of structure changes of the package and class folder structure), I used git pull and it worked properly.
The thing is, the change is shown in my local repository but not in eclipse. I don't how to make eclipse update.
Even though i delete the project from eclipse and reimport again but still didn't work
You need to import these new changes into your eclipse workspace after git pull.
In Git Repositories view go to the repository expand the the repository and right click on Working Directory then select Import projects.. then a wizard will appear follow the instruction.

Am I using EGit and Eclipse correctly when working with repositories?

I'm trying to set up EGit with Eclipse and I've used neither of them before. I understand the basics around Git and Eclipse is more or less just another IDE. The problem I'm having is setting up a reasonable work environment.
I have file-server at home which I want to use as a Bare repository which I push and pull changes to. To test it out I've done the setup locally.
I have a bare repository created through the Git Repository perspective.
I've cloned that repository into a local non-bare repository.
I've created a project in a subdir of the non-bare repository (is this the way to go? Is it possible to do have the project directly in the workspace with the .git folder within it? So far I've had a lot of trouble with it when trying to create an Eclipse project out of it. What is the proper way to do it?)
I've made some changes to this cloned repository and added the indexes, committed the changes and attempted to push the changes to upstream.
The thing is that no changes are made to upstream. Would someone like to explain the procedure in doing the push so that I'm not misunderstanding something? Or am I completely wrong on utilizing a bare repository instead of just working non-bare?
As mentioned in this tutorial, you create your Git repo right where your project is (ie your .classpath and .project files are).
Pushing to a bare repo is a good idea (see the links mentioned in "Git - pull & push - production server")
You need though to specify what you want to push:
Click at least on "Add all branch spec".