Is it possible to clone only a single git branch in hudson ? Hudson version 2.2.0 with git plugin version 2.2.0 clones the entire specified project, thus occupying lot of space (which is expected to grow forever)
Thanks in advance.
Is it possible to clone only a single git branch in hudson ? Hudson version 2.2.0 with git plugin version 2.2.0 clones the entire specified project, thus occupying lot of space (which is expected to grow forever)
Thanks in advance.
Configuring refspec in the hudson-git plugin to the following value seems to be working:
+refs/heads/master:refs/remotes/origin/master
In 2023 that is not enough, the "Honor refspec on initial clone" option under "Advanced clone behaviours" must also be enabled.
Also "Shallow clone" can be enabled at the same place to save a bit more space (it omits downloading the history, it download only the latest version).
Not directly, but if you can adapt the Hudson Git Plugin itself, you could clone only a branch with the right git command:
See "How to clone a single branch in git?"
This is possible since git1.7.10:
git clone <url> --branch <branch> --single-branch <folder>
Note that the git plugin 2.0 will allow to specify the right branch to clone:
You are confusing clone
with checkout
. Clone clones a repository, and that's how git works, checkout wil switch you to a given branch. Git is distributed thus, whole repository is copied with clone to your local machine. So you can access any branch, commit, tag, ever pushed.
A git "branch" is just a 40-byte bookmark pointing to a position in the project history -- unless your branches are massively divergent, you aren't really saving much space, as you'll be downloading the full history anyway.
If space saving is the goal, perhaps use the "shallow clone" option? That'll only download one layer of history, rather than all of it.