Skip to content

How to read the file data from GIT Repo. without cloning it in local using JGIT API

I tried to find a way to fetch particular file data from GIT Repo. without cloning that file in local using JGit API but didn’t found anything related to this. Now , I doubt is there any built in function available in JGit API to allow remote server viewing?

Please can anyone guide me on this?

Edit-1: My GIT repo. is hosted on BitBucket.


JGit is just a wrapper for automating Git specific tasks. If its not available in Git then it shouldn’t be available in JGit either. File download is not a Git specific feature, its more like a Git Repository Provider specific feature; for example, Bitbucket and GitHub provides this feature.

Since your repository is hosted on Bitbucket then you should look into their File Download Rest API. You should try to make a custom wrapper for automating this cURL request:

curl -s -L{workspace}/{repo_slug}/downloads/{file-name}