25

What is the difference between Refspec and Branch specifier (blank for default): in the below Jenkins job configuration:

enter image description here

I have tried to set the Refspec option in the job configuration:

+refs/heads/master:refs/remotes/origin/master

In the cloned repo on my build slave the .git/config file looks like this:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://user:pass@git.internal.com/scm/PROJECT/project.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

It seems that the value for fetch is not correct (read from the jenkins job configuration). Further it has no effect on the diskspace consumption.

u123
  • 15,603
  • 58
  • 186
  • 303
  • Obviously, the config of the repository is not affected. I'm not sure if this is the expected behavior or not but it should be noted that it is not strictly required since the refspec can afaik also be included in the git fetch command. Thus, you should try to check which command **really** gets executed. – bigge Mar 17 '13 at 12:09

1 Answers1

28

Refspec defines options for the fetch operation (see here and here) whereas the branch specifier defines which branch contains the code to be built by Jenkins. In other words: Refspec only defines how the code is retrieved while branch specifier which part of the code is going to be compiled.

[Edit:] Fixed broken link to refspec

Community
  • 1
  • 1
bigge
  • 1,488
  • 15
  • 27
  • Ok so if I only need to build eg. **my-feature** branch would it make sense to set refspec to **my-feature**? Would that save some space instead of fetching the complete repository/all branches? – u123 Mar 16 '13 at 15:17
  • Well, in principle that's true but keep in mind that git does a really good job in keeping branches lightweight. That is, git only saves differences and thus the overhead of fetching multiple branches will only be significant if the branches are **extremely** different form each other – bigge Mar 16 '13 at 19:09
  • It has no effect on diskspace consumption, but it seems that the option is never set - see edited post. – u123 Mar 17 '13 at 09:58
  • The git-scm link is dead now. I couldn't find a replacement though. – Mrchief Jan 21 '16 at 14:44