Skip to content

fatal: A branch named 'main' already exists. #1388

Open
@nschloe

Description

In a GitHub action, I create a fresh repo with

      - name: Create new GitHub repository
        run: |
          curl \
            --request POST \
            --header "Accept: application/vnd.github+json" \
            --header "Authorization: Bearer ${{ secrets.MY_TOKEN }}"\
            --header "X-GitHub-Api-Version: 2022-11-28" \
            --data '{
              "name": "foobar",
              "private": true,
              "visibility": "private",
            }' \
            --url "https://api.github.com/orgs/<org>/repos"

I'd like to deploy to this repo with

      - name: Deploy to GitHub
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          token: ${{ secrets.MY_TOKEN }}
          repository-name: "<org>/foobar"
          branch: main
          folder: deploy/
          single-commit: true

This then fails with

Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config --global --add safe.directory /__w/baz/baz
/usr/bin/git config user.name nschloe
/usr/bin/git config user.email [email protected]
/usr/bin/git config core.ignorecase false
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
/usr/bin/git remote add origin ***github.com/<org>/foobar.git
Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/<org>/foobar.git refs/heads/main
Creating worktree…
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD fb01a93)
/usr/bin/git checkout --orphan main
fatal: A branch named 'main' already exists.

Any idea what's going wrong?

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions