| how to tell git to use a remote repository [message #753210] |
Wed, 26 October 2011 13:21  |
julius 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 #753390 is a reply to message #753365] |
Wed, 26 October 2011 20:57   |
julius 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: Wed, 26 October 2011 21:00] Report message to a moderator
|
|
|
|
| Re: how to tell git to use a remote repository [message #753457 is a reply to message #753411] |
Thu, 27 October 2011 06:47   |
julius 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 10:22] 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 11:04  |
Matthias Sohn Messages: 395 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.
|
|
|
Powered by
FUDForum. Page generated in 0.03446 seconds