Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » how to tell git to use a remote repository
how to tell git to use a remote repository [message #753210] Wed, 26 October 2011 17:21 Go to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
hi,


how do i tell egit to use a remote repository instead of storing it locally?

And where do i find the files that are needed for git clone to get a working copy?
i told egit to create the repository in the project folder, but theres only a checkout of the project not the "server" files.
Re: how to tell git to use a remote repository [message #753365 is a reply to message #753210] Wed, 26 October 2011 21:24 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
julius skrev 2011-10-26 19.21:
> hi,
>
>
> how do i tell egit to use a remote repository instead of storing it locally?

This is important: You *always* work with a local repository. Usually it starts out
as a clone of a repository somewhere, but obviously you can create new repositories.

If you clone a remote repository EGit will have a reference to the original,
which will be used for further updates (fetch) and possibly push.

>
> And where do i find the files that are needed for git clone to get a working copy?
> i told egit to create the repository in the project folder, but theres only a checkout of the project not the "server" files.

For most project there is a web page that tells you what the URL is that you should
pass to clone in order to clone the remote repository,.

See the EGit project page at Eclipse.org for further links to tutorial. Lars Vogel and GitHub
also have good tutorials.

-- robin
Re: how to tell git to use a remote repository [message #753390 is a reply to message #753365] Thu, 27 October 2011 00:57 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
i know that git always has a local copy.

i tried this to get a "fresh" project that uses a remote repository:

remote:
  cd /git-repos && mkdir testrepo && cd testrepo
  git --bare init

 local:
  cd localdir
  "touch 1 2 3"
  git init
  git add .  
  git commit -am 'bla'
  git remote add origin ssh://remotehost/git-repos/testrepo
  git push origin master



starting with eclipse -> file -> import -> git
since this "empty" repo does not contain a project i did choose "project wizard"

egit recognizes the remote repo, shows the master branch und starts the new project wizard.
their i choose java project and press finish - but now the project is not under version control, i can choose team -> share project....but why?
why does it not use the remote repo (and a local copy of that)?

[Updated on: Thu, 27 October 2011 01:00]

Report message to a moderator

Re: how to tell git to use a remote repository [message #753411 is a reply to message #753390] Thu, 27 October 2011 06:37 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Try the nightly build version of EGit and switch on the preference "Team > Git > Projects > Auto share projects located in a git repository".

Most operations in Git and also EGit work only on the local clone, remotes are used only for the few remote operations like push, fetch, ls-remotes. Hence if you do operations which are not of this class they work on the local repository only. Also a remote is just an alias for the URL used to reach that remote repository so that you don't need to type the full URL all the time, i.e. instead of "git push ssh://remotehost/git-repos/testrepo" this allows to say "git push origin" instead.

You can't create a remote repository from git / egit itself, instead you either need a Git server [1] or OS level access to the remote system in order to create a new repository. Usually this implies passing some permission checks established to protect the server.

[1] either use a hosting site like GitHub or if you want to host it on your own have a look at
- GitBlit http://code.google.com/p/gitblit/
- Gerrit http://code.google.com/p/gerrit/
- GitLab http://gitlabhq.com/
- gitosis http://progit.org/book/ch4-7.html
Re: how to tell git to use a remote repository [message #753457 is a reply to message #753411] Thu, 27 October 2011 10:47 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
Howto share a local project

create a new project in eclipse
"share it" with:
team -> share project -> git -> create...
for name enter mytest
finish -> finish

on the hosting machine do:
git --bare init
to create a empty repo

add something to your java project like a class, in this example i will use 123.
add it to the index, commit it
team -> add, team -> commit

now the description after the project name changes from NO HEAD to master

add this:
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://USER@HOST/egittest
[branch "master"]
    remote = origin
    merge = refs/heads/master

to ~/git/123/.git/config
change the url line

right click on project -> team -> push to upstream

for this to work you only need a empty git repo, its address and a eclipse project.







Howto import a existing java project

lets assume that the project is called lala3

1. create a new project called lala3 on your local machine
2. team -> share project -> git -> create
here you specify where git should store its local files, the default seems to be: ~/git as the parent dir. change that to whatever you want.
for name enter a diretory where the files end up in.i will use somename as example.
finish -> finish

3. add the lines below to ~/git/somename/.git/config
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://USER@HOST/egittest
[branch "master"]
    remote = origin
    merge = refs/heads/master

this is the standard git config file with the url where the remote repo resides.
you need to change the value for url.

4. create a temporary java class that is not part of the project to be imported, do team -> add, team -> commit
5. right click on the project -> team -> pull
and the magic happens.

[Updated on: Thu, 27 October 2011 14:22]

Report message to a moderator

Re: how to tell git to use a remote repository [message #753478 is a reply to message #753457] Thu, 27 October 2011 12:36 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
im pretty sure ive imported a project via file -> import using git as source on a different system using eclipse indigo.
egit is installed from http://download.eclipse.org/egit/updates

maybe a bug?

will try the nightly build
EDIT: no luck with the nightly build

[Updated on: Thu, 27 October 2011 14:24]

Report message to a moderator

Re: how to tell git to use a remote repository [message #753482 is a reply to message #753478] Thu, 27 October 2011 12:45 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
No Message Body

[Updated on: Thu, 27 October 2011 14:23]

Report message to a moderator

Re: how to tell git to use a remote repository [message #753544 is a reply to message #753390] Thu, 27 October 2011 15:55 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
julius skrev 2011-10-27 02.57:
> i know that git always has a local copy.
>
> i tried this to get a "fresh" project that uses a remote repository:
>
>
> remote:
> cd /git-repos && mkdir testrepo && cd testrepo
> git --bare init
>
> local:
> cd localdir
> "touch 1 2 3"
> git init
> git add . git commit -am 'bla'
> git remote add origin ssh://remotehost/git-repos/testrepo
> git push origin master
>
>
> since this "empty" repo does not contain a project i did choose "project wizard" from the eclipse options.
> egit recognizes the remote repo, shows the master branch und starts the new project wizard.
> their i choose java project and press finish - but now the project is not under version control, i can choose team -> share project....but why?
> why does it not use the remote repo (and a local copy of that)?

This is the way Eclipse wants us to explicitly connect project to version control.
Now we could actually connect them automatically. It would be unlike some of
the other team provider, but then there is really only one sensible mapping. We've
been discussing (I think), so sharing automatically might be an option, though

I know some people use two versions control systems with the same workspace, so
they might no like that.

-- robin
Re: how to tell git to use a remote repository [message #753559 is a reply to message #753544] Thu, 27 October 2011 16:53 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
ok, but could you add a message so that users get noticed?
maybe its just me, but if i press import from git i expect to get something that relates to git....i didnt even see content showing up right after import, although it downloaded the content.
Re: how to tell git to use a remote repository [message #753597 is a reply to message #753478] Thu, 27 October 2011 22:35 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
julius wrote on Thu, 27 October 2011 08:36
im pretty sure ive imported a project via file -> import using git as source on a different system using eclipse indigo.
egit is installed from http://download.eclipse.org/egit/updates

maybe a bug?

will try the nightly build
EDIT: no luck with the nightly build


did you try this with the nightly and the preference "Team > Git > Projects > Auto share projects located in a git repository" switched on ?
Re: how to tell git to use a remote repository [message #753669 is a reply to message #753597] Fri, 28 October 2011 09:44 Go to previous messageGo to next message
julius  is currently offline julius Friend
Messages: 17
Registered: October 2011
Junior Member
ah forgot that, will do that in a few hours on my home machine.

EDIT:
using the option "Team > Git > Projects > Auto share projects located in a git repository" doesnt work

choosing existing project does not recognizes a project in the repo
new project does create a new project but with no content

[Updated on: Fri, 28 October 2011 16:23]

Report message to a moderator

Re: how to tell git to use a remote repository [message #756736 is a reply to message #753457] Mon, 14 November 2011 21:00 Go to previous messageGo to next message
Mads M. Hansen is currently offline Mads M. HansenFriend
Messages: 14
Registered: July 2009
Junior Member
julius, is there anyway to set this config:

[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ssh://USER@HOST/egittest
[branch "master"]
remote = origin
merge = refs/heads/master


up for newly shared project form within eclipse?

It seems to be done automatically for repositories cloned from a remote server.

.. Mads

[Updated on: Mon, 14 November 2011 21:02]

Report message to a moderator

Re: how to tell git to use a remote repository [message #757307 is a reply to message #756736] Thu, 17 November 2011 16:04 Go to previous message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Yes, this configuration is established automatically when cloning from another repository. If you didn't clone it you may configure this e.g. from "Preferences > Team > Git > Configuration > Repository Settings > select your repository" but you have to enter these parameters manually.
Previous Topic:prohibited by Gerrit
Next Topic:[jgit] Problems to reuses an already cloned repo and tagging
Goto Forum:
  


Current Time: Tue Apr 23 13:39:01 GMT 2024

Powered by FUDForum. Page generated in 0.03865 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top