threads / discuss / 26262

JGIT newbie question

Subject: JGIT newbie question

## tl;dr

3 messages between Jan 11, 2011 and Jan 11, 2011.

replies: 2people: 2as markdown or json

sundarbun· Jan 11, 2011, 18:51 UTC · lore

Hi All: I am looking into using JGit from Java to get some files from source control for an application that runs on AWS. We currently use SVNKit and it seems to work fine. We recently made the switch to git and I am having a hard time finding a sample that allows one to (a) init or create a ocal repo with my credentials and path to the tree that I am interested in... (a) get a bunch of files from my remote repo (b) commit any changes back in...

I have searched through this list and have not had any luck.

If there is someone out there that can help me that would be much appreciated.

thanks! Sundarbun

-- 
View this message in context: http://git.661346.n2.nabble.com/JGIT-newbie-question-tp5911913p5911913.html
Sent from the git mailing list archive at Nabble.com.
Shawn Pearce· Jan 11, 2011, 19:30 UTC · re: sundarbun · lore

Re: JGIT newbie question

On Tue, Jan 11, 2011 at 10:51, sundarbun <sundarbun@yahoo.com> wrote:
> I am looking into using JGit from Java

JGit related questions are probably better directed to the jgit-dev@eclipse.org mailing list, as that is the list most of the JGit contributors monitor and answer questions on. The project is hosted at http://www.eclipse.org/jgit/ so you may find more resources there too, including the latest 0.10.1 release.

Show 7 quoted lines
> to get some files from source control
> for an application that runs on AWS.
> We currently use SVNKit and it seems to work fine. We recently made the
> switch to git and I am having a hard time finding a sample that allows one
> to
> (a) init or create a ocal repo with my credentials and path to the tree that
> I am interested in...

Use the Git object in the org.eclipse.jgit.api package. There is an init method that can create a new repository at the given directory.

> (a) get a bunch of files from my remote repo
Try the checkout() method on the Git object.
> (b) commit any changes back in...
Try the commit() method on the Git object.

But if you want to avoid using the working directory, you'll need to go through a much lower-level API, setting up your own DirCache, and using an ObjectReader and ObjectInserter to interact with the Repository class. Doing this requires some knowledge of the basic Git data model (commits, trees, blobs).

-- 
Shawn.
sundarbun· Jan 11, 2011, 21:58 UTC · re: Shawn Pearce · lore

Re: JGIT newbie question

Thanks Shawn.. I did look at the jGit list and I will post there as well.
>>But if you want to avoid using the working directory
Not sure what this means.. perhaps I have to read up some more...

I got as far as what you have suggested with the Git object in the org.eclipse.jgit.api jar.

Where I got stumped was the specification of the userid/pwd/repo path parameters that tells git when I init it (as I run on an aws machine with no .git directory initially) to setup shop in a temp working directory that I specify in the init.

I was hoping to have an init command that I could pass a valid git repo url, a user name and pwd and local fileDir so that a .git would be created and then I can call checkout to get the part of the tree that I am interested in.

If you have any insight.. I'd appreciate your comments.

thanks again. S

-- 
View this message in context: http://git.661346.n2.nabble.com/JGIT-newbie-question-tp5911913p5912619.html
Sent from the git mailing list archive at Nabble.com.

← back to recent threads