Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » Fetch(How to do a fetch)
Fetch [message #781297] Fri, 20 January 2012 22:51 Go to next message
Luis Lara is currently offline Luis LaraFriend
Messages: 5
Registered: January 2012
Junior Member
HI JGit team!

I was trying to use jgit to do a pull or fetch, but i am not able to do it

I tried

My repository is located in a file called test so I did

FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File("test")).readEnvironment().findGitDir().build();
Git git = new Git(repository);
PullCommand pc = git.pull();
pc.call();

And it gave me this error

Pull on repository without HEAD currently not supported

I am not sure what it means,
Please help me out, thanks

LC
Re: Fetch [message #782140 is a reply to message #781297] Mon, 23 January 2012 08:49 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 612
Registered: July 2009
Senior Member
Check if the repository you are trying to pull from contains any commits. A fresh empty repository might have HEAD not yet defined. To check this run "git show-ref --head" and check if it lists "HEAD".
Re: Fetch [message #782208 is a reply to message #782140] Mon, 23 January 2012 10:45 Go to previous messageGo to next message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 18
Registered: July 2009
Junior Member
Also check this: you should have a currently checkout-out branch in the repo from which you do pull. The error message tells you that we can't resolve the current HEAD in your local repo - the repo into which you want to pull. Maybe it's a very new repo where the master branch is not yet born (no commit has been done yet to master).
Re: Fetch [message #782565 is a reply to message #782208] Tue, 24 January 2012 00:26 Go to previous messageGo to next message
Luis Lara is currently offline Luis LaraFriend
Messages: 5
Registered: January 2012
Junior Member
Hi Thank you for your reply

The GIT Repository I am using is this
egit.eclipse.org/jgit.git


I was able to do a GIT fetch/pull with TortoiseGUI
With pull I get this
Pull on repository without HEAD currently not supported



With get I get this origin: not found.


If I use fetch setting teh remote location the GIT URL: git.fetch().setRemote("egit.eclipse.org/jgit.git").call();
I got
org.eclipse.jgit.errors.TransportException: Nothing to fetch.
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1038)


git show-ref --head shows this
Please help me!, THanks!

D:\PushToTest\TCS\TCS1.5.1\modules\GIT\jgit>git show-ref --head
96acc4e5cfb84a181874007074b956763db347bb HEAD
3fa054bcf7ff60fdf2ec6f48728a1d6b52a8c14e refs/heads/master
3fa054bcf7ff60fdf2ec6f48728a1d6b52a8c14e refs/heads/mts
96acc4e5cfb84a181874007074b956763db347bb refs/heads/stable-1.2
3fa054bcf7ff60fdf2ec6f48728a1d6b52a8c14e refs/remotes/origin/master
51d1af9489924ff03fa10ec963110c608c2882a3 refs/remotes/origin/stable-0.10
989149736ad1cd09c15e143aa598028b9f9b6502 refs/remotes/origin/stable-0.11
b2b58feba7400269df8b31ef8495b695af3a9793 refs/remotes/origin/stable-0.12
be863689766bd74451ce687f8580cccd458b0d4b refs/remotes/origin/stable-0.7
d28a40d6790e321fbd9cb8d9b945308fe0e0fca4 refs/remotes/origin/stable-0.8
26f507f0df5822df0f19a5ca16462a4bbfeab5fc refs/remotes/origin/stable-0.9
6646c72d1723d5c01d68a0d02e0eb26c90bdd345 refs/remotes/origin/stable-1.0
57d6585522af279d311b11af64339c209c08f6be refs/remotes/origin/stable-1.1
a069e90fa9ab0262df471797e9b77505a3396f23 refs/remotes/origin/stable-1.2
8bbde7aacf771a9afb6992434f1ae413e010c6d8 refs/tags/spearce-gpg-pub
42977e7b1fc075fc6f2fc520ccc5ea328c9b136d refs/tags/v0.10.1
f5847db3c229348f7e519900bc88ea4f142f8fe3 refs/tags/v0.11.1
fe25d5693bb45634d72b05771c5c9a9691d16c60 refs/tags/v0.11.3
74828c91ebd25b7bf9d3dbdf8a01769ba44fc1ba refs/tags/v0.12.1
a0850fe2ee26a67a45d425b79a9cfdc4d43b6742 refs/tags/v0.7.0
b10834cdfe77627fecf8eccd8bc49815ff00a568 refs/tags/v0.7.1
2339b3b81ead3d2bb186d3bf6924c5376cc90858 refs/tags/v0.8.1
e2666d0f8ccde5aa7feeca8c0c4187ee74862c3e refs/tags/v0.8.4
d4c5c2274d5ff4ba9ec2c378bb1067dc2bd752e2 refs/tags/v0.9.1
1af326d2c772f5cc136ef5fd2c4a24b6773d496d refs/tags/v0.9.3
4309f66554e91b9f51247f61deef27f4163975d4 refs/tags/v1.0.0.201106011211-rc3
d28091fb2977077471138fe97da1440e0e8ae0da refs/tags/v1.0.0.201106051725-r
8f315bec1a902abc95d961af5b2acc18a36aadda refs/tags/v1.0.0.201106071701-r
ae8625aa5b198989483196be2cdd31f2d8091db9 refs/tags/v1.0.0.201106081625-r
f56191efb9d01bd973ca2f92c8606e208f464764 refs/tags/v1.0.0.201106090707-r
ff3986d9f24ca4a97ca72db67c45f857af98a7f9 refs/tags/v1.1.0.201109011030-rc2
353f8f342548baebd62aaa2bf905f084b4babffa refs/tags/v1.1.0.201109071825-rc3
b2f3aa2599e495591a5c2e01eef7ddf9dc18e568 refs/tags/v1.1.0.201109151100-r
d36d497f2c1916e7fc879fee3e521e6c9bc93eef refs/tags/v1.2.0.201112221803-r
Re: Fetch [message #782566 is a reply to message #782565] Tue, 24 January 2012 00:27 Go to previous messageGo to next message
Luis Lara is currently offline Luis LaraFriend
Messages: 5
Registered: January 2012
Junior Member
The URL starts with http, I didn't added because the form showed an error
Re: Fetch [message #782622 is a reply to message #782566] Tue, 24 January 2012 04:17 Go to previous message
Luis Lara is currently offline Luis LaraFriend
Messages: 5
Registered: January 2012
Junior Member
Found it!

I have to point the File to the .git folder instead of this parent folder!

Case closed, thanks!

This code works!
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File("test/.git")).readEnvironment().findGitDir().build();
Git git = new Git(repository);
PullCommand pc = git.pull();
pc.call();
Previous Topic:Better credentials verification
Next Topic:EGit and RemoteTools (PTP)
Goto Forum:
  


Current Time: Wed Nov 26 13:16:05 GMT 2014

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

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