Eclipse and Git: Difference between revisions

From Redbrick Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
So after having a bit of a head bashing session getting an eclipse project to work nicely with a git repository hosted on github, I thought I'd throw my approach up here to save others torture.
So after having a bit of a head bashing session getting an eclipse project to work nicely with a git repository hosted on github, I thought I'd throw my approach up here to save others torture.


== Eclipse git plugin ==
==Eclipse git plugin==
I'm using EGit.
I'm using EGit.


I used Eclipse's Update Manager, adding http://download.eclipse.org/egit/updates as the site for the plugin.
I used Eclipse's Update Manager, adding http://download.eclipse.org/egit/updates as the site for the plugin.


== Eclipse Project ==
==Eclipse Project==
I went about setting up my project in eclipse as per usual, noting the location of my workspace.
I went about setting up my project in eclipse as per usual, noting the location of my workspace.


== Git Repo ==
==Git Repo==
I'm using ubuntu, so I installed the necessary git tools with the following command:
I'm using ubuntu, so I installed the necessary git tools with the following command:


<code>
<code>
sudo apt-get install git-core
sudo apt-get install git-core
</code>
</code>


I then opened a terminal and cd'd to the location of my project in the eclipse workspace, noted above.
I then opened a terminal and cd'd to the location of my project in the eclipse workspace, noted above.


<code>
<code>
cd /home/dregin/workspace/Project-Name/
cd /home/dregin/workspace/Project-Name/
</code>
</code>


I then set up a .git repo following the steps provided by github, [http://help.github.com/creating-a-repo/ here].
I then set up a .git repo following the steps provided by github, [http://help.github.com/creating-a-repo/ here].


<code>
<code>
git config --global user.name "My Name"
git config --global user.name "My Name"
git config --global user.email email@address.com
git config --global user.email email@address.com
</code>
</code>


'''NOTE:''' At this point the steps want you to create/move into a directory, but we're already in the directory we're going to use.
'''NOTE:''' At this point the steps want you to create/move into a directory, but we're already in the directory we're going to use.


<code>
<code>
git init
git init
git add .
git add .
git commit -m 'My first commit'
git commit -m 'My first commit'
git remote add origin git@github.com:username/repository-name.git
git remote add origin git@github.com:username/repository-name.git
push origin master
push origin master
</code>
</code>
'''NOTE:''' If this isn't your first commit to the repository you plan on using you should merge with the remote repository as follows:
'''NOTE:''' If this isn't your first commit to the repository you plan on using you should merge with the remote repository as follows:
<code>
<code>
git fetch origin
git fetch origin
git merge origin/master
git merge origin/master
push origin master
push origin master
</code>
</code>
==Making Eclipse Play With The New Repo==
* In the package explorer, right-click on the package name.
** Team > Share Project.
* Choose "Git".
It should see the repository that you setup above.
* Click Finish.
That should be you done.
This page is a shit on the face of style. Please fix it.

Latest revision as of 23:15, 9 November 2010

So after having a bit of a head bashing session getting an eclipse project to work nicely with a git repository hosted on github, I thought I'd throw my approach up here to save others torture.

Eclipse git plugin

I'm using EGit.

I used Eclipse's Update Manager, adding http://download.eclipse.org/egit/updates as the site for the plugin.

Eclipse Project

I went about setting up my project in eclipse as per usual, noting the location of my workspace.

Git Repo

I'm using ubuntu, so I installed the necessary git tools with the following command:


sudo apt-get install git-core


I then opened a terminal and cd'd to the location of my project in the eclipse workspace, noted above.


cd /home/dregin/workspace/Project-Name/


I then set up a .git repo following the steps provided by github, here.


git config --global user.name "My Name"

git config --global user.email email@address.com


NOTE: At this point the steps want you to create/move into a directory, but we're already in the directory we're going to use.


git init

git add .

git commit -m 'My first commit'

git remote add origin git@github.com:username/repository-name.git

push origin master


NOTE: If this isn't your first commit to the repository you plan on using you should merge with the remote repository as follows:


git fetch origin

git merge origin/master

push origin master


Making Eclipse Play With The New Repo

  • In the package explorer, right-click on the package name.
    • Team > Share Project.
  • Choose "Git".

It should see the repository that you setup above.

  • Click Finish.

That should be you done.

This page is a shit on the face of style. Please fix it.