Branch is no longer checked out when using refspec
Original discussion started in https://forum.gitlab.com/t/src-refspec-master-does-not-match-any/24691 all the jobs that were posted was because they are trying to push a specific branch. Using refspec we don't check out a branch but checkout a specific commit.
Steps to reproduce
Have a job trying to push master
deploy: stage: deploy script: - git remote add heroku https://heroku:[email protected]/<project>.git && git push -f heroku master environment: name: production url: https://<project>.herokuapp.com only: - master
A user would get the error
Src refspec master does not match any
The user can push master to any remote.
Relevant logs and/or screenshots
A job running
git branch as part of the script.
Used GitLab Runner version
Regression most likely introduced in !1203 (merged)
Use HEAD when you want to push this to another remote.
deploy: stage: deploy script: - git remote add heroku https://heroku:[email protected]/<project>.git - git push -f heroku HEAD:master
At first, we were implementing !1270 (merged) as a fix but decided to revert it in !1283 (merged) since it had some bad performance regressions. The behavior we had was flaky at best for the following reasons described in #4097 (comment 156508723)