Branch is no longer checked out when using refspec
Summary
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:$HEROKU_API_KEY@git.heroku.com/<project>.git && git push -f heroku master
environment:
name: production
url: https://<project>.herokuapp.com
only:
- master
Actual behavior
A user would get the error Src refspec master does not match any
Expected behavior
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
11.9
Regression most likely introduced in !1203 (merged)
Workaround
Use HEAD when you want to push this to another remote.
deploy:
stage: deploy
script:
- git remote add heroku https://heroku:$HEROKU_API_KEY@git.heroku.com/<project>.git
- git push -f heroku HEAD:master
⚠
Wont Fix 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)