问题
I m writing a web application where it accepts the git URL and file to read and then displays the file on the webpage. I m using JGit for this. I see that JGit needs a local repository to clone before viewing the file. Since this is server, I do not have access to local files. So, is there anyway I can access the git remotely and view the file from there?
Thanks
回答1:
It's not just JGit that needs a local repository, Git itself requires a local repository. Centralized version control systems like CVS and SVN had remote server viewing built-in, but decentralized systems (such as Git and Mercurial) typically do not.
If you want to browse a Git server, you have to make a local clone, but you could do this in the background for the user.
You might also be interested in the GitHub API, which lets you do what you want, but only for repositories hosted by GitHub.
来源:https://stackoverflow.com/questions/19414568/viewing-file-from-git-using-jgit-remotely-without-creating-local-repo