Checkout: fatal: You are not currently on a branch.

Created on 2 Aug 2020  路  2Comments  路  Source: actions/checkout

config

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm ci
      - name: Build CSS
        run: npm run build
      - name: Push to GitHub
        run: |
          git config user.name github-actions
          git config user.email [email protected]
          git add .
          git commit -m "Build CSS"
          git push

log

Run git config user.name github-actions
  git config user.name github-actions
  git config user.email [email protected]
  git add .
  git commit -m "Build CSS"
  git push
  shell: /bin/bash -e {0}
[detached HEAD 706b5f8] Build CSS
 2 files changed, 2 insertions(+), 2 deletions(-)
 rewrite dist/css/plane.min.css.map (83%)
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>

##[error]Process completed with exit code 128.

tried (not working)

    fetch-depth: 0
    ref: ${{ github.event.pull_request.head.ref }}
    fetch-depth: 0
    ref: master

Most helpful comment

I had same issue running push command in pull request. I managed to dig down into this old issue. It seems like the problem is that pull requests are not the same as regular branches, and solution ended up being to add this configuration option to my script:

uses: actions/checkout@v2
with:
  ref: ${{ github.event.pull_request.head.ref }}

All 2 comments

I seem to get the same ... I am running on a self-hosted runner that generates files and would like to commit back to the repo but get exactly the same as above.

I had same issue running push command in pull request. I managed to dig down into this old issue. It seems like the problem is that pull requests are not the same as regular branches, and solution ended up being to add this configuration option to my script:

uses: actions/checkout@v2
with:
  ref: ${{ github.event.pull_request.head.ref }}
Was this page helpful?
0 / 5 - 0 ratings