Skip to main content



      Home
Home » Eclipse Projects » EGit / JGit » How to Fork and Clone Only the Default Branch Using JGit(Optimizing JGit Fork Process: Cloning Only the Default Branch)
How to Fork and Clone Only the Default Branch Using JGit [message #1872980] Mon, 02 December 2024 14:39 Go to next message
Eclipse UserFriend
I am looking to optimize the forking process using JGit by limiting it to fetch and clone only the default branch (e.g., main) of a repository instead of all branches.

Problem:
Currently, JGit retrieves all branches during the clone operation, which is unnecessary for our workflow and increases data transfer and storage usage.

Objective:
I want to ensure that only the default branch is forked and cloned, similar to the option available in the GitHub web interface.

Questions for the Community:
Is there a JGit feature or method that allows fetching only the default branch during the clone operation?
If no such feature exists, are there any best practices or workarounds to achieve this while continuing to use JGit?
Re: How to Fork and Clone Only the Default Branch Using JGit [message #1872986 is a reply to message #1872980] Tue, 03 December 2024 03:05 Go to previous messageGo to next message
Eclipse UserFriend
CloneCommand.setCloneAllBranches(false)
Re: How to Fork and Clone Only the Default Branch Using JGit [message #1872992 is a reply to message #1872986] Tue, 03 December 2024 04:10 Go to previous message
Eclipse UserFriend
Find examples in the tests, e.g. [1].

Please note that this forum is deprecated and will be closed soon. You can ask question in GitHub discussions [2] or raise an GitHub issue [3].

[1] https://github.com/eclipse-jgit/jgit/blob/master/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java#L418
[2] https://github.com/eclipse-jgit/jgit/discussions
[3] https://github.com/eclipse-jgit/jgit/issues
Previous Topic:authentication not supported (when accessing Git repository from Overleaf)
Next Topic:Getting Not Authrized whille Pushing
Goto Forum:
  


Current Time: Tue May 13 00:59:45 EDT 2025

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

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

Back to the top