edgecase/middleman-gh-pages

fatal: remote origin already exists.

Closed this issue · 9 comments

❯ rake publish
******
cd /Users/mehulkar/dev/personal/mehulkar.github.io
cd -
cd /Users/mehulkar/dev/personal/mehulkar.github.io/build
git init
Reinitialized existing Git repository in /Users/mehulkar/dev/personal/mehulkar.github.io/build/.git/
git remote add origin git@github.com:mehulkar/mehulkar.github.io.git
fatal: remote origin already exists.
rake aborted!
Command failed with status (128): [git remote add origin git@github.com:mehul...]
/Users/mehulkar/.rvm/gems/ruby-2.1.1/gems/middleman-gh-pages-0.0.3/lib/middleman-gh-pages/tasks/gh-pages.rake:22:in `block (2 levels) in <top (required)>'
/Users/mehulkar/.rvm/gems/ruby-2.1.1/gems/middleman-gh-pages-0.0.3/lib/middleman-gh-pages/tasks/gh-pages.rake:20:in `block in <top (required)>'
/Users/mehulkar/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/mehulkar/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => publish => prepare_git_remote_in_build_dir => /Users/mehulkar/dev/personal/mehulkar.github.io/build/.git/refs/remotes/origin/gh-pages
(See full trace by running task with --trace)

+1 on this issue. Are there any fixes for this yet?

+1 anyone have any insight?

I wonder if its an ordering of steps issue - I feel like maybe I did something out of order? I've found a fair bit of confusion because Github pages expects /master to be the deployment branch, not gh-pages

+1 Just tried using this and am running into the same issue. Any update?

This fix should do it for me. Can we get this merged and deployed to rubygems?

Question, was this fix actually pushed to master? (dont see it?)

rmm5t commented

Question, was this fix actually pushed to master? (dont see it?)

It was, but then it was immediately reverted, because it was problematic with brand new build directory initialization.

Instead, if you still have this error with the latest version of middleman-gh-pages, just blow away your build directory and run rake publish again. Afterwards, everything should be back in sync.

If there is still trouble after that, please report back, and we'll investigate a more appropriate fix.

The issue is still happening for me after I delete the build directory

rmm5t commented

@milesalex Thanks for chiming in here. To help further debug this, would you mind pasting here both the output of bundle list | grep middleman-gh and the output of bundle exec rake publish --trace (after the build directory is removed with rm -rf build)?

rmm5t commented

For those that are still having issues with this particular issue of "fatal: remote origin already exists" ...

Is it possible that you have a remove.origin config in your global git config (~/.gitconfig)? It would look something like this:

[remote "origin"]
  # ...
  # specific config for origin remotes
  # ...

It's best not to have a global config for your origin remote like this. Otherwise, git is tricked into thinking that an origin remote already exists on all new git init repositories.