0

I have a python script that generates two graphs which I have to push back to SCM. (PLEASE NOTE THAT MASTER BRANCH DOES EXIST) Now running this script is automated (run every 12 hours) so finally I have the stage to push code back. Here's the stage

        stage('Pushing results') {
        steps{
            script{
                withCredentials([gitUsernamePassword(credentialsId: 'johncena')]) {
                sh '''
                    git config --global user.name "randyorton"
                    git config --global user.email randyorton@example.com
                    git add .
                    git commit -m "Updated results"
                    git push -u origin master
                '''
                }
            }
        }
    }

However I get the error:

error: src refspec master does not match any

error: failed to push some refs to (repo url)

JS_Rudra
  • 5
  • 5
  • https://stackoverflow.com/search?q=%5Bgit%5D+error%3A+src+refspec+master+does+not+match+any – phd Oct 20 '22 at 07:35
  • `git push -u origin main` – phd Oct 20 '22 at 07:35
  • there is no main branch, master is the (main) branch. – JS_Rudra Oct 20 '22 at 07:42
  • ***error: src refspec master does not match any*** means there is no `master` branch. If you're sure there is also no `main` then you have to list branches with `git branch --all`, `git show-branch`, `git for-each-ref`. – phd Oct 20 '22 at 07:49
  • using HEAD:master finally solved this error. Do you have any idea why this is so? – JS_Rudra Oct 20 '22 at 08:31
  • `git push origin HEAD:master` means "push the current local branch (whatever it is) to the remote `master`". You don't have local `master` so you pushed another local branch, most probably `main`. – phd Oct 20 '22 at 08:33

0 Answers0