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

Command failed: git branch --force development --track origin/development #193

Open
lensbart opened this issue Apr 15, 2021 · 6 comments · May be fixed by #205
Open

Command failed: git branch --force development --track origin/development #193

lensbart opened this issue Apr 15, 2021 · 6 comments · May be fixed by #205
Labels
bug Something isn't working

Comments

@lensbart
Copy link

Hello!

First of all, thanks for making this.

A few days ago, I had everything set up fine and my GitHub Action was succesfully linting pull requests on master using Prettier, ESLint and Stylelint. However, in the mean time I did something that makes this lint action fail on every run:

Command failed: git branch --force development --track origin/development
error: the requested upstream branch 'origin/development' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

The steps I took that I think might have caused this problem:

  • Delete origin/development (I know, bad idea — I wanted to remove a certain commit)
  • Reset the local branch to a previous commit and discard the local changes
  • Push development to the remote

After some further testing, it seems that I cannot reuse the name development for any newly created branch (and then run a PR against master).

@alexbbt
Copy link

alexbbt commented Apr 30, 2021

I think this is related to #13 (comment). I am looking for a fix

alexbbt added a commit to alexbbt/lint-action that referenced this issue Apr 30, 2021
alexbbt added a commit to alexbbt/lint-action that referenced this issue Apr 30, 2021
@alexbbt alexbbt linked a pull request Apr 30, 2021 that will close this issue
@ocean90
Copy link
Member

ocean90 commented May 2, 2021

I'm wondering if the whole checkOutRemoteBranch() function/process is still required and if we can't instead rely on the actions/checkout@v2 action.

There's a comment about why this function exists in

lint-action/src/index.js

Lines 42 to 50 in b98b091

// Fetch and check out PR branch:
// - "push" event: Already on correct branch
// - "pull_request" event on origin, for code on origin: The Checkout Action
// (https://github.com/actions/checkout) checks out the PR's test merge commit instead of the
// PR branch. Git is therefore in detached head state. To be able to push changes, the branch
// needs to be fetched and checked out first
// - "pull_request" event on origin, for code on fork: Same as above, but the repo/branch where
// changes need to be pushed is not yet available. The fork needs to be added as a Git remote
// first

And I think this has been fixed in v2 of the checkout action, see the release notes.

@alexbbt
Copy link

alexbbt commented May 4, 2021

Oh interesting! It seems like it could be removed then! I will try running the tests with it removed and see if it works

@ocean90 ocean90 added the bug Something isn't working label May 26, 2021
@toddburnside
Copy link

Is there any update on this. We are unable to run our lint jobs for pull requests because of this issue. We don't autofix, anyway, so there is really no reason for us to do a checkout.

@jaxonL
Copy link

jaxonL commented Jun 6, 2023

hello, any updates on this? i'm trying to do what was suggested in #498 for a monorepo, but the action fails on the second call within a same workflow with a similar error:

fatal: cannot force update the branch 'chore/eslint-rules' checked out at '/home/runner/work/my-repo/my-repo'
Error: Command failed: git branch --force chore/eslint-rules --track origin/chore/eslint-rules

the workflow is set up like so:

# setup omitted
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      runs-on: ubuntu-latest
      steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '16.x'
          cache: 'yarn'

      - name: Test monorepo
        run: yarn test

      - name: Run lint action on SDK
        uses: wearerequired/lint-action@v2
        with:
          check_name: 'ESLint/SDK'
          auto_fix: false
          commit: false
          eslint: true
          eslint_dir: packages/sdk
          eslint_extensions: js,ts

      - name: Run lint action on React library
        uses: wearerequired/lint-action@v2
        with:
          check_name: 'ESLint/React'
          auto_fix: false
          commit: false
          eslint: true
          eslint_dir: packages/react
          eslint_extensions: js,ts,tsx
# rest of workflow file omitted

@samuliasmala
Copy link

Any update on this? We're having the same issue as @jaxonL and the only solution we found was to create two separate jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants