kandi background
Explore Kits

jgit-cookbook | Provides examples and code snippets

 by   centic9 Java Version: Current License: Apache-2.0

 by   centic9 Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | jgit-cookbook Summary

jgit-cookbook is a Java library. jgit-cookbook has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub.
Provides examples and code snippets for the [JGit](https://eclipse.org/jgit/) Java Git implementation. The JGit framework is rich and diverse, it has two layers, a low-level api and a higher-level set of porcelain commands. This can be a bit intimidating at first as there are lots of classes, some of which are not relevant for most tasks. This project tries to provide a collection of ready-to-run snippets which provide a quick start for building functionality using JGit. Please make sure to take a look at the nicely written [introduction](http://www.codeaffine.com/2015/12/15/getting-started-with-jgit/) and also use the existing [JavaDoc](http://download.eclipse.org/jgit/site/ and the [User Guide](http://wiki.eclipse.org/JGit/User_Guide) as well, as they are well done and provide detailed information and a general overview of JGit respectively. Just import the project in your IDE and start up the Main application, see the Comments in the code for more details. Another simple way to start the sample-server is to run ./gradlew run in the httpserver-directory. If you find these snippets useful and would like to support it, you can [Sponsor the author](https://github.com/sponsors/centic9).

kandi-support Support

  • jgit-cookbook has a medium active ecosystem.
  • It has 1307 star(s) with 430 fork(s). There are 68 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 2 open issues and 35 have been closed. On average issues are closed in 76 days. There are no pull requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of jgit-cookbook is current.
jgit-cookbook Support
Best in #Java
Average in #Java
jgit-cookbook Support
Best in #Java
Average in #Java

quality kandi Quality

  • jgit-cookbook has 0 bugs and 0 code smells.
jgit-cookbook Quality
Best in #Java
Average in #Java
jgit-cookbook Quality
Best in #Java
Average in #Java


  • jgit-cookbook has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • jgit-cookbook code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
jgit-cookbook Security
Best in #Java
Average in #Java
jgit-cookbook Security
Best in #Java
Average in #Java

license License

  • jgit-cookbook is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
jgit-cookbook License
Best in #Java
Average in #Java
jgit-cookbook License
Best in #Java
Average in #Java


  • jgit-cookbook releases are not available. You will need to build from source code and install.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
jgit-cookbook Reuse
Best in #Java
Average in #Java
jgit-cookbook Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed jgit-cookbook and discovered the below as its top functions. This is intended to give you an instant insight into jgit-cookbook implemented functionality, and help decide if they suit your requirements.

  • Entry point for testing .
    • Run the testbook .
      • Returns the elements at the given path in the given repository .
        • Obtains the number of lines of a file in a given commit .
          • This method is used to create a temporary repository .
            • Writes the archive to a temporary file
              • Prints the README .
                • Returns the diff entry .
                  • Creates a new repository .
                    • Creates a new commit .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      jgit-cookbook Key Features

                      [Open an existing repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/OpenRepository.java)

                      [Create a new repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/CreateNewRepository.java)

                      [Initialize a new repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/InitRepository.java)

                      [Add a new file to the index](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/AddFile.java)

                      [Commit a file to an existing repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CommitFile.java)

                      [Commit all changes](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CommitAll.java)

                      [List commits (i.e. Log)](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowLog.java)

                      [List all tags in a repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListTags.java)

                      [List all branches in a repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListBranches.java)

                      [List all commits in a repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/WalkAllCommits.java)

                      [List uncommitted changes of a repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListUncommittedChanges.java)

                      [Create and delete branches](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CreateAndDeleteBranch.java)

                      [Create and delete tags](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CreateAndDeleteTag.java)

                      [Revert a modified tracked file back to its original state in most recent commit](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/RevertChanges.java)

                      [Return diff between two branches](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowBranchDiff.java)

                      [Show diff of changes to a file between two revs](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowFileDiff.java)

                      [Show diff of changes to all files between two commits](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowChangedFilesBetweenCommits.java)

                      [Show diff of changes to a file between two commits when the file has been renamed](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/DiffRenamedFile.java)

                      [Show Status](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowStatus.java)

                      [Store contents of branch into a compressed file](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CreateArchive.java)

                      [Write contents of branch into a compressed file using a custom archive format](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CreateCustomFormatArchive.java)

                      [Blame, i.e. find out which commit changed specific lines in a file](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ShowBlame.java)

                      [Add and list Notes attached to commits](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/AddAndListNoteOfCommit.java)

                      [List available Notes](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListNotes.java)

                      [Clean all untracked files](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CleanUntrackedFiles.java)

                      [Create, list, apply and drop stashes](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CreateListApplyAndDropStash.java)

                      [Run garbage collection](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CollectGarbage.java)

                      [Blame, i.e. retrieve information who last changed which line in a file](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/BlameFile.java)

                      [Merge changes from a branch](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/MergeChanges.java)

                      [List changed files between two commits](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/DiffFilesInCommit.java)

                      [Clone a remote repository into a new local directory](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CloneRemoteRepository.java)

                      [Iterate remote references in a repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListRemotes.java)

                      [List remote heads/tags without a local clone](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/ListRemoteRepository.java)

                      [Fetch from remote repositories](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/FetchRemoteCommits.java)

                      [Fetch from remote repositories and use prune to remove outdated remote branches/tags](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/FetchRemoteCommitsWithPrune.java)

                      [Fetch from remote repositories via ssh protocol](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/FetchRemoteCommitsWithSshAuth.java)

                      [Clone a remote repository via SSH protocol and username/password credentials](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CloneRemoteRepositoryWithAuthentication.java)

                      [Rebase onto an upstream branch](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/RebaseToOriginMaster.java)

                      [Using InMemoryRepository to clone a Git repo in-memory and work from there](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CloneRemoteRepositoryIntoMemoryAndReadFile.java)

                      [Checkout a PR from GitHub](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/porcelain/CheckoutGitHubPullRequest.java)

                      [Get the SHA-1 ref from a name, e.g. refs/heads/master](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetRefFromName.java)

                      [Get the commit-object from a name or a SHA-1](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetRevCommitFromObjectId.java)

                      [Get the commit-message](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetCommitMessage.java)

                      [Get the tree-object from a commit-object, name or SHA-1](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetRevTreeFromObjectId.java)

                      [Read the contents of a file/blob](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ReadBlobContents.java)

                      [Get the tag-object from a name or a SHA-1](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ReadTagFromName.java)

                      [Resolve complex references, e.g. HEAD^^ to a SHA-1](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ResolveRef.java)

                      [Iterate over the commits on a branch](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/WalkRev.java)

                      [Iterate over a range of commits](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/WalkFromToRev.java)

                      [Read contents of a specific file from a specific commit](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ReadFileFromCommit.java)

                      [List remotes configured for the current repository](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/PrintRemotes.java)

                      [Print out user information from Git](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ReadUserConfig.java)

                      [Read file attributes, e.g. executable state, file or directory, size, …​](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetFileAttributes.java)

                      [Use class BranchTrackingStatus to retrieve number of commits ahead/behind compared to remote branches](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ShowBranchTrackingStatus.java)

                      [Check if commits on other branches are merged into a given branch](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/CheckMergeStatusOfCommit.java)

                      [List files in a directory as-of a specific commit or a tag](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ListFilesOfCommitAndTag.java)

                      [Iterate over files of a commit recursively](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/WalkTreeRecursive.java)

                      [Iterate over files of a commit non-recursively](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/WalkTreeNonRecursive.java)

                      [Find all commits that are reachable via tags, branches, remotes, HEADs, …​](https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/WalkAllCommits.java)

                      There is a standalone sub-project in directory [httpserver](https://github.com/centic9/jgit-cookbook/blob/master/httpserver) which starts up a simple HTTP Git server based on the JGit GitServlet.

                      Iterate all commits of a repository: https://gerrit.googlesource.com/plugins/branch-network/+log/refs/heads/master/src/main/java/com/googlesource/gerrit/plugins/branchnetwork/data/JGitFacade.java

                      Take some of the unit tests as example: https://github.com/eclipse/jgit/tree/master/org.eclipse.jgit.test/tst/org/eclipse/jgit/api

                      SubModules: http://stackoverflow.com/questions/13426798/jgit-read-gitmodules http://www.codeaffine.com/2014/04/16/how-to-manage-git-submodules-with-jgit/ https://stackoverflow.com/questions/26090139/jgit-reading-commits-from-a-submodule https://download.eclipse.org/jgit/site/

                      Diffing: http://stackoverflow.com/questions/12987364/how-to-diff-with-two-files-by-jgit-without-creating-repo

                      Amend a previous commit: http://stackoverflow.com/questions/4772142/jgit-unstaging-files-removing-files-from-the-index-and-ammending-a-commit

                      Remove a file from the index: http://stackoverflow.com/questions/4803462/jgit-java-git-library-unstaging-files

                      Git repo on Amazon S3: http://stackoverflow.com/questions/8744611/git-repository-on-s3-as-origin-not-as-backup http://stackoverflow.com/questions/7031729/publish-to-s3-using-git http://www.fancybeans.com/blog/2012/08/24/how-to-use-s3-as-a-private-git-repository/

                      CherryPick: http://download.eclipse.org/jgit/site/ http://stackoverflow.com/questions/18300898/how-to-cherry-pick-a-commit-that-has-more-than-one-parent

                      More authentication: http://www.lordofthejars.com/2016/09/authenticating-with-jgit.html

                      How to do a shallow clone (i.e. --depth 1) as soon as https://bugs.eclipse.org/bugs/show_bug.cgi?id=475615 is implemented

                      [JGit JavaDoc](http://download.eclipse.org/jgit/site/

                      [JGit User Guide](http://wiki.eclipse.org/JGit/User_Guide)

                      [JGit related questions on stackoverflow](http://stackoverflow.com/questions/tagged/jgit)

                      [AlBlue’s Blog: Embedding JGit](http://alblue.bandlem.com/2013/11/embedding-jgit.html)

                      [JGit main page](http://www.eclipse.org/jgit/)

                      EGit - Git plugin for Eclipse - https://www.eclipse.org/egit/

                      Gerrit - A web-based team code collaboration tool - https://www.gerritcodereview.com

                      Gitiles - A simple Git repository browser - http://code.google.com/p/gitiles/ and https://android.googlesource.com

                      JGitFS - A userfs implementation which allows to browse branches, tags, committs as a directory structure - https://github.com/centic9/JGitFS

                      jgitstats - displays repository stats - https://github.com/selesse/jgitstats

                      git-to-solr - Index git history into a Solr repository - https://github.com/arafalov/git-to-solr

                      Elegit - GUI client for people who want to learn Git - https://github.com/dmusican/Elegit

                      jgit-cookbook Examples and Code Snippets

                      See all related Code Snippets


                      copy iconCopydownload iconDownload
                      git clone git://github.com/centic9/jgit-cookbook

                      Is it possible to use JGit's in-memory repository to add one small file to a big Git repository without checking it out locally?

                      copy iconCopydownload iconDownload
                      git clone --depth 1 <repo_url> -b <branch_name>

                      See all related Code Snippets

                      Community Discussions

                      Trending Discussions on jgit-cookbook
                      • Is it possible to use JGit's in-memory repository to add one small file to a big Git repository without checking it out locally?
                      Trending Discussions on jgit-cookbook


                      Is it possible to use JGit's in-memory repository to add one small file to a big Git repository without checking it out locally?

                      Asked 2020-Oct-12 at 14:01

                      I have a large (several GB) Git repository. I want some application to create small files within that repository and commit the changes. This should happen without checking out those gigabytes to the disk.

                      I found a JGit code sample in which a remote repository is cloned into an in-memory respository.

                      Can I use JGit (something like shown below) in order to add a file to a remote repository without checking it out locally (i. e. without transferring gigabytes of data to the machine where that code will run)?

                      DfsRepositoryDescription repoDesc = new DfsRepositoryDescription();
                      InMemoryRepository repo = new InMemoryRepository(repoDesc);
                      Git git = new Git(repo);

                      Update 1: The size of the entire directory (tracked files plus .git) is 1.2G. The size of .git alone is 573M.

                      % du -hs .
                      1.2G    .
                      % du -hs .git
                      573M    .git


                      Answered 2020-Oct-12 at 14:01

                      Note that a checkout in RAM will download the exact same data from the remote. It will just use 1,2G in RAM, rather than on disk, after the clone is completed.

                      You may also want to see how you can create and add a "file" using JGit api, to see if it is a convenient way to add the data you want to your repo.

                      If you want to limit the amount of stuff that's downloaded from your git server : you can create a shallow clone.
                      see this SO answer for example :

                      git clone --depth 1 <repo_url> -b <branch_name>

                      This will download the inner files for the latest commit (a compressed version of the 500M in your case), and run an actual checkout (the 500M) of this commit.

                      You can run this either on disk, or in RAM, depending on your needs.

                      In your situation, this would still require something in the 600-700M usage, in RAM or on disk, including the checked out files,
                      but it would download only ~100M (I'm guessing : check the actual size by running the shallow clone command from your workstation) from the server for the compressed version of the head commit.

                      Source https://stackoverflow.com/questions/64292837

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network


                      No vulnerabilities reported

                      Install jgit-cookbook

                      You can download it from GitHub.
                      You can use jgit-cookbook like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the jgit-cookbook component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .


                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Java Libraries
                      Try Top Libraries by centic9
                      Compare Java Libraries with Highest Support
                      Compare Java Libraries with Highest Quality
                      Compare Java Libraries with Highest Security
                      Compare Java Libraries with Permissive License
                      Compare Java Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.