s0 / git-publish-subdir-action

GitHub Action to push a subdirectory as a branch to any git repo (e.g. for GitHub Pages)
https://github.com/marketplace/actions/push-git-subdirectory-as-branch
MIT License
210 stars 36 forks source link

Refusing to fetch into current branch of non bare repository #9

Closed KyrietS closed 4 years ago

KyrietS commented 4 years ago

Problem

When I try to push a folder into different repository to master branch I always get the warning:

Failed to fetch target branch, probably doesn't exist

When your action clones the target repo, it's already on master branch so then "git fetch origin master:master" fails and throws an error.

Solution

There are a few ways to solve this. The simplest one is to add "-u,--update-head-ok" to the line 261 of index.js

await exec(`git fetch -u origin ${config.branch}:${config.branch}` [...]

I tested this solution and the warning has gone.

Hope it helps :-)