Need some help setting up Git/EGit/GitHub for the first time - eclipse

I am creating a totally new OSS project for my organisation and I want to host it on GitHub. The project will be developed using Eclipse and I am using EGit. I have no prior experience with Git, as I've previously only used SVN.
Here's what I did so far:
Created a new account for my organisation on GitHub. (I already had a personal account.)
Created a new repository under my organisation's GitHub account for this project.
Under the new repository's "Collaborators" section, added my personal account. (I verified this in my personal account.)
Installed EGit into my Eclipse. (I am using Eclipse 4.2 with EGit 2.0.0)
Created a new Eclipse project in a new Eclipse workspace. (It's a Maven project so I created it through m2e but that shouldn't make a difference.)
Added the new Eclipse project to a new Git local repository (via Team -> Share Project).
Created the .gitignore (ignores Eclipse-specific files and directories).
Added source to the project (via Team -> Add to Index).
Committed local changes to my local repository.
Copied the HTTPS URL from GitHub.
Team -> Remote -> Push
The URL from the clipboard was already taken and most fields populated.
Entered username and password for my GitHub personal account, clicked Next, data was fetched successfully.
Selected "refs/head/master" from the Source ref dropdown (I didn't understand this entire page, maybe I've put something wrong?)
Clicked "Add Spec" and then Next
At this point, I got the error "master: master [rejected - non-fast-forward]"
I searched on Google, but the suggested resolution was to do a Pull. I tried "Team -> Pull", but got the error "The current branch is not configured for pull; No value for key branch.master.merge found in configuration"
Can anyone help me? My remote repo is still empty (save for the .gitignore and the README.md). I want to get files from my local into that remote repo!!

That looks like there is already committed content in your Github repository. I don't exactly know what is going wrong, but I would do it different:
First install Mylyn and the Mylyn GitHub connector in Eclipse. That way you can access github repositories much easier.
Use the Mylyn Github connector to clone your existing (assumed to be empty) Github repository into a new local repository (File->Import->Git->From Github). That is the easiest way to verify your login credentials, ssh keys and so on.
During the previous cloning step, the github repository was automatically added as "upstream" repository reference to your local repository. So if you now add files to your local repository, you can commit them and afterwards use "Push to upstream" to make them available on Github. No configuration of the remotes and refspecs is necessary in that case.
Now create your new Eclipse project and share it using the Team -> Share, where you select your existing local repository.
Everything beyond that would be as you already described.

Related

Does Github Project Classic not exist anymore?

In my previous Github repos, I was able to create a project under the repo which was specific to the repo, but now I cannot see this option for the new repos.
I can still use Project (Classic) in my previous repos.
Github now push me to create a project under my account, and link to the repo, but I want to create a project just under the repo.
In my side, the problem is that, when I try to create an "Issue", the user can see all of my projects under my account, but I don't want that.
The user should only see the related project.
Can I somehow have the previous version of the projects?
Thanks

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.

Pulling a project from GitHub with EGit

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.

How can I start a project on GitLab repo with Eclipse?

Good morning.
I just create a GitLab private repo to work in a project with some people. When I add GitLab repo to Eclipse, it says there aren't projects (and it's true). I would know how to create a project and sync with online repo so other members can see my project and codes.
I tried to start a project in git\repoName\ folder, then right-click and choose Team->Commit, but changes wouldn't save (in gitLab repo's website, it says "Repo is empty").
I tried to follow some online guides, but without success.
Sorry for bad english!
Eclipse 4.2 and newer, comes default with (E)Git installed. There is a good Eclipse git tutorial from Vogella.
Create a GitLab git repository
Log into GitLab
Create a project / git repository
Copy the https url from the project, used for cloning
Adding an GitLab git repository in Eclipse
Open the Git perspective in Eclipse
Use Clone existing Git repo, as shown in Using git repository view
Now all the git functionality from Eclipse can be used.
I assume you have a cloned repository available in Eclipse (eGit) that is empty. If not, follow the steps in the answer from Verhagen.
By now, you have a cloned repository that is marked with "[NO HEAD]", indicating that no commit has been made.
Start creating a new project by using your project type of choice; I'll use Java project for simplicity: File menu > New > Java project
in the New Java Project wizard un-tick the "Use default Workspace location" checkbox; instead, choose the directory where you cloned your empty GitLab project, and append the name of the project (this is to make Eclipse create a directory inside the repository, just in case you later want to create more projects in the same repo).
Fill in the wizard as you usually do. When you are done with the different steps, you'll have a new project, that is also marked with "[NO HEAD]"
Create some source files you want to share (e.g. HelloWorld.java)
Synchronize workspace (right click on the new project > Team > Synchronize workspace) you will see that now there are files to commit. Pay attention to those files, since some of them ( .gitignore, and maybe .classpath, .project,.settings directory... depending on how you share your projects) you'll want to add to the .gitignore.
right click on the files you want to commit, fill in the commit message and click "Commit and Push". Click Next
Since it is a new repository, you'll have to configure the Push action. I selected HEAD as source and HEAD as destination. You might want to do the same, at least for this first commit+push; later on, you might choose to add some specs for branches, etc.
The Push Confirmation will show you that the new branch master:master will be created.
Both project and repository lost the "[NO HEAD]" marking
You can check gitlab site to confirm your files are there.

Using egit with github and eclipse 3.8.1 on ubuntu 13.10

I am new to eclipse, and I can't figure otu how to set up egit properly to work with github. I made a new local repository, and I've commited some changes, but now I want to get all this code onto github. What should I do? I can't find a solution in the eclipse wiki. I have a github account.
Here is a nice demo that show you step by step video
What you want to do is pulling up repository in eclipse from window -> show view -> other (then find the repository)
After you did that you go to master branch and configure remote then add your SSH key under your github account. Go to your eclipse git destination from remote enter your git account URL, username, password, repository path. All you need to do after that just hit the push.