0

I configured the following command in Jenkins to push change on gitA to gitB repository. However I got the following error:

 error: src refspec ... does not match any. error: failed to push some refs to ...

+ /usr/local/bin/git remote rename origin upstream
+ /usr/local/bin/git remote add origin ssh:<gitB repo>
+ /usr/local/bin/git fetch origin
 * [new branch]      master     -> origin/master
+ /usr/local/bin/git push origin master
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://<git repo>
Build step 'Execute shell' marked build as failure
Finished: FAILURE

However, I tried to git push origin origin/master and the Jenkins job execution is successful but no commit on the destination repo.

I have added ssh key. Please suggest what is missing here. I also tried to see the source branch using git branch and it's correct.

Niels de Bruin
  • 705
  • 5
  • 15
Jackie Ham
  • 11
  • 3
  • Possible duplicate of [src refspec master does not match any when pushing commits in git](https://stackoverflow.com/questions/4181861/src-refspec-master-does-not-match-any-when-pushing-commits-in-git) – phd Jan 05 '18 at 16:14

1 Answers1

0

Seems like you are trying to push an empty repository. Add the initial commit.

  • git add .
  • git commit -m "initial commit"
  • git push origin master
  • git push upstream master
Ishan Thilina Somasiri
  • 1,179
  • 1
  • 12
  • 24