Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal: You are not currently on a branch. #317

Closed
bidipeppercrap opened this issue Aug 2, 2020 · 6 comments
Closed

fatal: You are not currently on a branch. #317

bidipeppercrap opened this issue Aug 2, 2020 · 6 comments

Comments

@bidipeppercrap
Copy link

bidipeppercrap commented Aug 2, 2020

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
@bidipeppercrap bidipeppercrap changed the title Can't push fatal: You are not currently on a branch. Aug 2, 2020
@domgreen
Copy link

domgreen commented Aug 6, 2020

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.

@sigute
Copy link

sigute commented Dec 2, 2020

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 }}

michaelborn added a commit to michaelborn/cbwire that referenced this issue Nov 9, 2021
1. pull request events are "funny", so we need to check out using `github.event.pull_request.head.ref` if the workflow step will commit anything. See actions/checkout#317 (comment)
2. Regular push events just check out the regular branch, but if this is enabled on multiple branches we need the ability to get the branch name dynamically. Use the new `GITHUB_REF_NAME` variable.
@ChrisAcrobat
Copy link

ChrisAcrobat commented Aug 20, 2022

Two years later.
I just had this problem as well, but I'm not working with a pull request. This solved it for me:

uses: actions/checkout@v3
with:
  ref: ${{ github.ref_name }}

@cezar-tech
Copy link

cezar-tech commented Jun 23, 2023

3 years later I also had this problem

uses: actions/checkout@v3
with:
  ref: ${{ github.ref_name }}

solved it for me

JacksonBurns added a commit to JacksonBurns/use-rse-23-astartes that referenced this issue Jul 10, 2023
ValarDragon added a commit to osmosis-labs/osmosis that referenced this issue Aug 8, 2023
ValarDragon added a commit to osmosis-labs/osmosis that referenced this issue Aug 8, 2023
* Try committing result

* fix indent

* fix cmd

* try-token

* Tryfix

* try again

* Try again

* try docs suggested method

* try simpler thing

* ah wrong perms at top

* try agian

* Try actions/checkout#317

* try actions/checkout#719

* Generated protofile changes

* Try again

* Generated protofile changes

* use proper paths filtering

* Make it do make proto-all

* Rename workflow, add go.sum to diff list

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: devbot-wizard <[email protected]>
p0mvn pushed a commit to osmosis-labs/osmosis that referenced this issue Aug 29, 2023
* Try committing result

* fix indent

* fix cmd

* try-token

* Tryfix

* try again

* Try again

* try docs suggested method

* try simpler thing

* ah wrong perms at top

* try agian

* Try actions/checkout#317

* try actions/checkout#719

* Generated protofile changes

* Try again

* Generated protofile changes

* use proper paths filtering

* Make it do make proto-all

* Rename workflow, add go.sum to diff list

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: devbot-wizard <[email protected]>
@kunaljubce
Copy link

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 }}

This solution is a life saver. Thanks!

kenoir added a commit to wellcomecollection/developers.wellcomecollection.org that referenced this issue Feb 15, 2024
kenoir added a commit to wellcomecollection/developers.wellcomecollection.org that referenced this issue Feb 15, 2024
@Sddilora
Copy link

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 }}

This solution is a life saver. Thanks!

This also resolved our issue. Thanks a lot.

invisibleroads added a commit to python-organizers/conferences that referenced this issue May 22, 2024
rizblie added a commit to rizblie/aws-ecs-cicd-terraform that referenced this issue Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants