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 Breaks After Deleting the gh-pages Branch #349

Open
JimLynchCodes opened this issue Apr 8, 2020 · 4 comments · May be fixed by #364
Open

Command Breaks After Deleting the gh-pages Branch #349

JimLynchCodes opened this issue Apr 8, 2020 · 4 comments · May be fixed by #364

Comments

@JimLynchCodes
Copy link

JimLynchCodes commented Apr 8, 2020

Hi, I was pushing and my code was not being updated so out of frustration I deleted the entire gh-pages branch.

Now the gh-pages command doesn't work at all...

npm run deploy

> phaser-fish@0.1.0 deploy /Users/jlynch/Git-Projects/Phaser-Fish/phaser-fish-single-player
> gh-pages -d ./build

fatal: couldn't find remote ref refs/heads/gh-pages

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! phaser-fish@0.1.0 deploy: `gh-pages -d ./build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the phaser-fish@0.1.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jlynch/.npm/_logs/2020-04-08T19_14_51_596Z-debug.log

I would expect it to just re-create the gh-pages branch as I did when I ran the command for the first time...

antongolub added a commit to antongolub-forks/gh-pages that referenced this issue Jul 1, 2020
@antongolub
Copy link

antongolub commented Jul 1, 2020

@JimLynchCodes, СС @tschaub

This logic already exists, but it's a little bit broken.

Git.prototype.checkout = function(remote, branch) {
  const treeish = remote + '/' + branch;
  return this.exec('ls-remote', '--exit-code', '.', treeish).then(
    () => {
      // branch exists on remote, hard reset
      return this.exec('checkout', branch)
        .then(() => this.clean())
        .then(() => this.reset(remote, branch));
    },
    error => {
      if (error instanceof ProcessError && error.code === 2) {
        // branch doesn't exist, create an orphan
        return this.exec('checkout', '--orphan', branch);
      } else {
        // unhandled error
        throw error;
      }
    }
  );
};

git ls-remote checks that target remote branch exists by treeish pattern. Once it throws exit code 2, git checkout --orphan gh-pages is called to create a new one.

Mentioned error is related to return this.exec('checkout', branch) invocation, and it throws 1 which does not match to error.code === 2 condition. Probably your repository has a ref (tag / local branch) that satisfy treeish.

@tschaub
Copy link
Owner

tschaub commented Jul 31, 2020

I deleted the entire gh-pages branch.

@JimLynchCodes - do you recall what you did to delete the branch? Something like git push --delete origin gh-pages? Or git branch -D gh-pages? Or something else?

@loayjah
Copy link

loayjah commented Dec 12, 2021

@JimLynchCodes - do you recall what you did to delete the branch?

I had the same issue and used git push origin --delete gh-pages to delete the branch

@michitaro
Copy link

Related to #17 ?

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

Successfully merging a pull request may close this issue.

5 participants