jenkinsci / jenkinsci/git-plugin

[JENKINS-65183] Default branch handling is missing in pipeline git step

Open
#3,644 2 comments 0 reactions 0 assignees View on GitHub
component:git-plugin imported-jira-issue pipeline priority:minor resolution:unresolved ux
Dominant language
Java
Stars
694
Forks
1.1k
Avg merge
1h 29m
Merged PRs (30d)
3

Description

Currently many GitHub projects are changing the default branch from master to main.  Some projects have both branches.  The following produce different results:

Shell:

git clone url #checks out main


Pipeline:

git 'url' # checks out master 

It is certainly possible to specify a branch in both git and checkout step, but the default behavior is unintuitive.  As the default branch switch to main continues, I expect to encounter many (more) projects that have both branches (for better or for worse).

I noticed that docs were recently updated (JENKINS-64320), but I don't believe that every job referencing a repository (in this way) should change when the upstream default branch configuration changes.

---
Originally reported by akom, imported from: Default branch handling is missing in pipeline git step


  • status: Open
  • priority: Minor
  • component(s): git-plugin
  • label(s): pipeline, user-experience
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-02

Raw content of original issue

Currently many GitHub projects are changing the default branch from master to main.  Some projects have both branches.  The following produce different results:

Shell:



git clone url #checks out main



Pipeline:



git 'url' # checks out master 


It is certainly possible to specify a branch in both git and checkout step, but the default behavior is unintuitive.  As the default branch switch to main continues, I expect to encounter many (more) projects that have both branches (for better or for worse).

I noticed that docs were recently updated (JENKINS-64320), but I don't believe that every job referencing a repository (in this way) should change when the upstream default branch configuration changes.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.