Merge a branch into main from GitHub workflow

I’m new to GitHub and Actions. I am trying to merge a branch into main within a workflow which was triggered by a push event on same branch.

name: Merge dev branch to main
runs-on: ubuntu-latest

  - uses: actions/checkout@v2
      ref: 'main'
  - name: Merge Branches
    run: |
      git fetch dev
      git checkout dev
      git merge dev

But the step fails with the following error message:

fatal: ‘dev’ does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Process completed with exit code 128.

Any help in resolving this will be much appreciated.


The first parameter for git fetch needs to be a repository or remote name, so the fetch command should be something like:

git fetch origin

You can add another parameter to limit which refs to fetch, see: Git - git-fetch Documentation

Thank you! It did clear the error.

1 Like